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 11–15 of 16
Which of the following system calls results in the sending of SYN packets?
Answer: (D)
- makes a new socket of a given socket type. The socket is identified by an integer, and system resources are given to it. It sends no packet.
- is mostly used on the server side. It ties a socket to a socket address structure, which means a given local port number and IP address. It sends no packet.
- is used on the server side. It puts a bound TCP socket into the listening state. It sends no packet.
- is used on the client side. It gives the socket a free local port number. For a TCP socket, it tries to set up a new TCP connection.
When the client calls , the three-way handshake takes place:
1. The client asks for a connection by sending a SYN (synchronize) message to the server.
2. The server accepts the request by sending SYN-ACK back to the client.
3. The client replies with an ACK, and the connection is set up.
So only sends a SYN packet.
Answer: (D)
- is mostly used on the server side. It ties a socket to a socket address structure, which means a given local port number and IP address. It sends no packet.
- is used on the server side. It puts a bound TCP socket into the listening state. It sends no packet.
- is used on the client side. It gives the socket a free local port number. For a TCP socket, it tries to set up a new TCP connection.
When the client calls , the three-way handshake takes place:
1. The client asks for a connection by sending a SYN (synchronize) message to the server.
2. The server accepts the request by sending SYN-ACK back to the client.
3. The client replies with an ACK, and the connection is set up.
So only sends a SYN packet.
Answer: (D)
The contents of the text file t1.txt containing four lines are as follows :
a1 b1
a2 b2
a3 b2
a4 b1
The contents of the text file t2.txt containing five lines are as follows :
a1 c1
a2 c2
a3 c3
a4 c3
a5 c4
Consider the following Bourne shell script :
Which one of the following strings will NOT be present in the output generated when the above script is run? (Note that the given strings may be substrings of a printed line.)
a1 b1
a2 b2
a3 b2
a4 b1
The contents of the text file t2.txt containing five lines are as follows :
a1 c1
a2 c2
a3 c3
a4 c3
a5 c4
Consider the following Bourne shell script :
awk -F ' ' '{print $1, $2}' t1.txt |
while read a b ; do
awk -v aV=$a -v bV=$b -F ' ' '
aV == $1 {print aV, bV, $2}' t2.txt
done Which one of the following strings will NOT be present in the output generated when the above script is run? (Note that the given strings may be substrings of a printed line.)
Answer: (C)
The first awk prints the two columns of each line of t1.txt, so the loop reads the pairs (a, b) = (a1, b1), (a2, b2), (a3, b2), (a4, b1).
For each pair, the second awk scans t2.txt and prints aV, bV and column 2 of every t2 line whose column 1 equals aV.
a1 matches "a1 c1" and prints "a1 b1 c1".
a2 matches "a2 c2" and prints "a2 b2 c2".
a3 matches "a3 c3" and prints "a3 b2 c3".
a4 matches "a4 c3" and prints "a4 b1 c3".
(a5 in t2.txt matches nothing in t1.txt.)
So the output has "b1 c1", "b2 c3" and "b1 c3". The pair "b1 c2" never appears, because c2 goes with a2, and a2 goes with b2, not b1.
Answer: (C)
For each pair, the second awk scans t2.txt and prints aV, bV and column 2 of every t2 line whose column 1 equals aV.
a1 matches "a1 c1" and prints "a1 b1 c1".
a2 matches "a2 c2" and prints "a2 b2 c2".
a3 matches "a3 c3" and prints "a3 b2 c3".
a4 matches "a4 c3" and prints "a4 b1 c3".
(a5 in t2.txt matches nothing in t1.txt.)
So the output has "b1 c1", "b2 c3" and "b1 c3". The pair "b1 c2" never appears, because c2 goes with a2, and a2 goes with b2, not b1.
Answer: (C)
A user level process in Unix traps the signal sent on a Ctrl-C input, and has a signal handling routine that saves appropriate files before terminating the process. When a Ctrl-C input is given to this process, what is the mode in which the signal handling routine executes?
Answer: (A)
Pressing Ctrl-C is handled first by the kernel (the terminal driver), which sends the signal SIGINT to the process. This part runs in kernel mode.
The process has installed its own handler. The handler is ordinary code written by the user and it lives in the process's own address space. The kernel does not run user code with full privileges, so it switches back to user mode and runs the handler there. When the handler returns, the process goes back into the kernel briefly (the sigreturn call) and then continues.
Why the others are wrong: kernel mode and privileged mode are two names for the same CPU mode, and the handler does not run in it. "Superuser" is a kind of user (root) and not a CPU mode.
Answer: (A)
The process has installed its own handler. The handler is ordinary code written by the user and it lives in the process's own address space. The kernel does not run user code with full privileges, so it switches back to user mode and runs the handler there. When the handler returns, the process goes back into the kernel briefly (the sigreturn call) and then continues.
Why the others are wrong: kernel mode and privileged mode are two names for the same CPU mode, and the handler does not run in it. "Superuser" is a kind of user (root) and not a CPU mode.
Answer: (A)
The shell command
is executed in /etc directory of a computer system running Unix. Which of the following shell commands will give the same information as the above command when executed in the same directory?
find -name passwd -print is executed in /etc directory of a computer system running Unix. Which of the following shell commands will give the same information as the above command when executed in the same directory?
Answer: (A)
find -name passwd -print prints the path of every file named passwd in the current directory and below. In /etc it tells you that a file named passwd exists there.ls passwd prints the name passwd if that file exists in the current directory, so it gives the same information. It does not search subdirectories, but it is the closest match.The other options work on the contents of the file:
cat passwd prints the contents, grep name passwd prints the lines containing the text "name", and grep print passwd prints the lines containing the text "print". None of them looks up a file by its name.Answer: (A)
Consider the following code fragment:
if (fork() == 0)
{ a = a + 5; printf("%d,%d\n", a, &a); }
else { a = a - 5; printf("%d, %d\n", a, &a); } Let u, v be the values printed by the parent process, and x, y be the values printed by the child process. Which one of the following is TRUE?Answer: (C)
Let be the value of a before fork.
fork() returns 0 in the child and a non-zero value in the parent. So the child runs the first branch and the parent runs the else branch.
Parent: . Child: . So , that is .
The child gets a copy of the parent's address space, so is at the same virtual (logical) address in both. The address printed by &a is a virtual address, so . The two copies of a sit in different physical memory, so changing a in one process does not change it in the other. That is why the values differ while the addresses are equal.
Options A and B are wrong because they give (the parent's value is the smaller one). Option D is wrong because it says the addresses differ.
Answer: (C)
fork() returns 0 in the child and a non-zero value in the parent. So the child runs the first branch and the parent runs the else branch.
Parent: . Child: . So , that is .
The child gets a copy of the parent's address space, so is at the same virtual (logical) address in both. The address printed by &a is a virtual address, so . The two copies of a sit in different physical memory, so changing a in one process does not change it in the other. That is why the values differ while the addresses are equal.
Options A and B are wrong because they give (the parent's value is the smaller one). Option D is wrong because it says the addresses differ.
Answer: (C)
Keep practising