Time Left - 20:00 mins

GATE CS : Operating Systems Champion Quiz 2

Attempt now to get your rank among 522 students!

Question 1

In serial data transmission, every byte of data is padded with a ‘0’ in the beginning and one or two ‘1’s at the end of byte because

Question 2

Consider the following statements about user level threads and kernel level threads. Which one of the following statements is FALSE?

Question 3

Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared Boolean variables S1 and S2 are randomly assigned.

Which one of the following statements describes the properties achieved?

Question 4

Three concurrent processes X, Y, and Z execute three different code segments that access and update certain shared variables. Process X executes the P operation (i.e., wait) on semaphores a, b and c; process Y executes the P operation on semaphores b, c and d; process Z executes the P operation on semaphores c, d, and a before entering the respective code segments. After completing the execution of its code segment, each process invokes the V operation (i.e., signal) on its three semaphores. All semaphores are binary semaphores initialized to one. Which one of the following represents a deadlock-free order of invoking the P operations by the processes?

Question 5

Consider Peterson’s algorithm for mutual exclusion between two concurrent processes i and j. The program executed by process is shown below.
Repeat
flag[i]=true;
turn=j;
while(P) do no-op;
Enter critical section, perform actions, then
exit critical section
Flag[i]=false;
Perform other non-critical section actions.
Until false;
For the program to guarantee mutual exclusion, the predicate P in the while loop should be

Question 6

The enter_cs ( ) and leave_CS ( ) functions to implement critical section of a process are realized using test-and-set instruction as follows:
void enter_CS(X)
{
while (test-and-set(X));
}
void leave_CS(X)
{
X=0 ;
}
In the above solution, X is a memory location associated with the CS and is initialized to 0. Now consider
the following statements:
I. The above solution to CS problem is deadlock-free.
II. The solution is starvation free.
III. The processes enter CS in FIFO order.
IV. More than one process can enter CS at the same time.
Which of the above statements are TRUE?

Question 7

A shared variable x, initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X reads x from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads x from memory, decrements by two, stores it to memory, and then terminates. Each process before reading x invokes the P operation (i.e., wait) on a counting semaphore S and invokes the V operation (i.e., signal) on the semaphore S after storing x to memory. Semaphore S is initialized to two. What is the maximum possible value of x after all processes complete execution?

Question 8

The functionality of atomic TEST-AND-SET assembly language instruction is given by the following C function.
int TEST-AND-SET (int *x)
{
int y;
A1: y=*x;
A2:*x=1;
A3: return y;
}

Complete the following C functions for implementing code for entering and leaving critical sections based on the above TEST-AND-SET instruction.
int mutex=0;
void enter-cs()
{
while (………………E1…………………);
}
void leave-cs()
{
……………E2………………..;
}
Find the blank entry at E2.

Question 9

Draw the process state transition diagram of an OS in which (i) each process is in one of the five states: created, ready, running, blocked (i.e. sleep or wait), or terminated, and (ii) only non-preemptive scheduling is used by the OS. Label the transitions appropriately.

Question 10

The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:
P(s): s = s – 1;
if s < 0 then wait;
V(s): s = s + 1;
if s <= 0 then wakeup a process waiting on s;
Assume that Pb and Vb, the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:
P(S):
Pb(Xb);
s = s – 1;
if ({s < 0) {
Vb(Xb);
Pb(Yb);
}
Else Vb(Xb);
V(s): Pb(Xb);
s = s + 1;
if (s <= 0) Vb(Yb);
Vb(Xb);
The initial values of Xb and Yb are respectively
  • 522 attempts
  • 2 upvotes
  • 18 comments
Apr 10GATE & PSU CS