System Call · Operating System
16 questions · asked in 11 of 27 years (2000–2026)
MCQ 11 · MSQ 2 · NAT 31-mark 12 · 2-mark 4
2000Questions per year2026
Questions 6–10 of 16
Identify the correct order in which a server process must invoke the function calls accept, bind, listen, and recv according to UNIx socket API.
Answer: (B)
On the server: first socket, then bind (links the address), listen (makes the socket passive), accept (takes one connection), and recv (reads the data).
Answer: bind, listen, accept, recv
Answer: bind, listen, accept, recv
A process executes the code
fork();
fork();
fork();
The total number of child processes created is
fork();
fork();
fork();
The total number of child processes created is
Answer: (C)
Every fork call makes the number of processes twice as large. After three forks there are processes altogether, and this count includes the first process.
Number of child processes = 8 1 = 7
Answer: 7
Number of child processes = 8 1 = 7
Answer: 7
Consider the execution of the following commands in a shell on a Linux operating system.
bash$ cat alpha
Mathematics
bash$ ln alpha beta
bash$ rm alpha
bash$ cat >> beta << SAME
Information Technology
SAME
bash$ cat beta
The output of the last command will be:
bash$ cat alpha
Mathematics
bash$ ln alpha beta
bash$ rm alpha
bash$ cat >> beta << SAME
Information Technology
SAME
bash$ cat beta
The output of the last command will be:
Answer: (B)
ln alpha beta makes beta a second name (a hard link) for the same file as alpha, with the same data on disk.rm alpha removes only the name alpha. The data stays because the name beta still points to it, so beta still holds Mathematics.cat >> beta << SAME appends the lines typed before the line SAME. The word SAME only marks the end of the input and is not written to the file. So Information Technology is added after Mathematics.cat beta prints Mathematics, then Information Technology.Answer: (B)
A process executes the following code
for (i = 0; i < n; i++) fork( );The total number of child processes created isAnswer: (B)
Each call to fork() creates one child, and the child continues from the same point, so it runs the remaining loop iterations too. So every fork doubles the number of processes.
After each loop iteration the count is 1, 2, 4, 8, ..., up to after iterations. Only one of these is the original process, and all the others are children. So the number of children is .
Answer: (B)
After each loop iteration the count is 1, 2, 4, 8, ..., up to after iterations. Only one of these is the original process, and all the others are children. So the number of children is .
Answer: (B)
A client process P needs to make a TCP connection to a server process S. Consider the following situation: the server process S executes a socket(), a bind() and a listen() system call in that order, following which it is preempted. Subsequently, the client process P executes a socket() system call followed by connect() system call to connect to the server process S. The server process has not executed any accept() system call. Which one of the following events could take place?
Answer: (A)
After
The client's
An error (option C) would come only if nothing were listening on the port (the client would get a reset) or if the backlog were full. Blocking (B) lasts only for the short handshake, and a core dump (D) does not occur.
Answer: (A)
listen(), the server's kernel handles the TCP handshake by itself. When the client's SYN arrives, the kernel replies with SYN+ACK and, once the client's ACK comes, puts the finished connection in the listen backlog queue.accept() does not take part in the handshake. It only removes an already established connection from that queue.The client's
connect() returns as soon as it gets the SYN+ACK, so it returns successfully even though the server process was preempted and has not called accept().An error (option C) would come only if nothing were listening on the port (the client would get a reset) or if the backlog were full. Blocking (B) lasts only for the short handshake, and a core dump (D) does not occur.
Answer: (A)
Keep practising