• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

OS Process Management

Question 21

Consider two processors P1 and P2 executing the same instruction set. Assume that under identical conditions, for the same input, a program running on P2 takes 25% less time but incurs 20% more CPI (clock cycles per instruction) as compared to the program running on P1. If the clock frequency of P1 is 1GHz, then the clock frequency of P2 (in GHz) is _________.
  • 1.6
  • 3.2
  • 1.2
  • 0.8

Question 22

Consider the procedure below for the Producer-Consumer problem which uses semaphores: GATECS2014Q30 Which one of the following is TRUE?
  • The producer will be able to add an item to the buffer, but the consumer can never consume it.
  • The consumer will remove no more than one item from the buffer.
  • Deadlock occurs if the consumer succeeds in acquiring semaphore s when the buffer is empty.
  • The starting value for the semaphore n must be 1 and not 0 for deadlock-free operation.

Question 23

The atomic fetch-and-set x, y instruction unconditionally sets the memory location x to 1 and fetches the old value of x n y without allowing any intervening access to the memory location x. consider the following implementation of P and V functions on a binary semaphore S.
void P (binary_semaphore *s)
{
    unsigned y;
    unsigned *x = &(s->value);
    do
    {
        fetch-and-set x, y;
    }
    while (y);
}
void V (binary_semaphore *s)
{
    S->value = 0;
} 
Which one of the following is true?
  • The implementation may not work if context switching is disabled in P
  • Instead of using fetch-and –set, a pair of normal load/store can be used
  • The implementation of V is wrong
  • The code does not implement a binary semaphore

Question 24

Barrier is a synchronization construct where a set of processes synchronizes globally i.e. each process in the set arrives at the barrier and waits for all others to arrive and then all processes leave the barrier. Let the number of processes in the set be three and S be a binary semaphore with the usual P and V functions. Consider the following C implementation of a barrier with line numbers shown on left. C
void barrier (void) {
1:   P(S);
2:   process_arrived++;
3.   V(S);
4:   while (process_arrived !=3);
5:   P(S);
6:   process_left++;
7:   if (process_left==3) {
8:      process_arrived = 0;
9:      process_left = 0;
10:  }
11:  V(S);
} 
The variables process_arrived and process_left are shared among all processes and are initialized to zero. In a concurrent program all the three processes call the barrier function when they need to synchronize globally. The above implementation of barrier is incorrect. Which one of the following is true?
  • The barrier implementation is wrong due to the use of binary semaphore S
  • The barrier implementation may lead to a deadlock if two barrier in invocations are used in immediate succession.
  • Lines 6 to 10 need not be inside a critical section
  • The barrier implementation is correct if there are only two processes instead of three.

Question 25

Barrier is a synchronization construct where a set of processes synchronizes globally i.e. each process in the set arrives at the barrier and waits for all others to arrive and then all processes leave the barrier. Let the number of processes in the set be three and S be a binary semaphore with the usual P and V functions. Consider the following C implementation of a barrier with line numbers shown on left. C
void barrier (void) {
1:   P(S);
2:   process_arrived++;
3.   V(S);
4:   while (process_arrived !=3);
5:   P(S);
6:   process_left++;
7:   if (process_left==3) {
8:      process_arrived = 0;
9:      process_left = 0;
10:  }
11:  V(S);
} 
The variables process_arrived and process_left are shared among all processes and are initialized to zero. In a concurrent program all the three processes call the barrier function when they need to synchronize globally. Which one of the following rectifies the problem in the implementation?
  • Lines 6 to 10 are simply replaced by process_arrived--
  • At the beginning of the barrier the first process to enter the barrier waits until process_arrived becomes zero before proceeding to execute P(S).
  • Context switch is disabled at the beginning of the barrier and re-enabled at the end.
  • The variable process_left is made private instead of shared

Question 26

Consider two processes P1 and P2 accessing the shared variables X and Y protected by two binary semaphores SX and SY respectively, both initialized to 1. P and V denote the usual semaphore operators, where P decrements the semaphore value, and V increments the semaphore value. The pseudo-code of P1 and P2 is as follows : P1 :

 While true do {
   L1 : ................
   L2 : ................
   X = X + 1;
   Y = Y - 1;
   V(SX);
   V(SY);             
 }

P2 :

 While true do {
   L3 : ................   
   L4 : ................
   Y = Y + 1;
   X = Y - 1;
   V(SY);
   V(SX);            
}

In order to avoid deadlock, the correct operators at L1, L2, L3 and L4 are respectively

  • P(SY), P(SX); P(SX), P(SY)

  • P(SX), P(SY); P(SY), P(SX)

  • P(SX), P(SX); P(SY), P(SY)

  • P(SX), P(SY); P(SX), P(SY)

Question 27

Suppose we want to synchronize two concurrent processes P and Q using binary semaphores S and T. The code for the processes P and Q is shown below.
Process P:
while (1) {
W:
   print \'0\';
   print \'0\';
X:
}
	
Process Q:
while (1) {
Y:
   print \'1\';
   print \'1\';
Z:
}
Synchronization statements can be inserted only at points W, X, Y and Z. Which of the following will always lead to an output starting with \'001100110011\' ?
  • P(S) at W, V(S) at X, P(T) at Y, V(T) at Z, S and T initially 1
  • P(S) at W, V(T) at X, P(T) at Y, V(S) at Z, S initially 1, and T initially 0
  • P(S) at W, V(T) at X, P(T) at Y, V(S) at Z, S and T initially 1
  • P(S) at W, V(S) at X, P(T) at Y, V(T) at Z, S initially 1, and T initially 0

Question 28

Suppose we want to synchronize two concurrent processes P and Q using binary semaphores S and T. The code for the processes P and Q is shown below.
Process P:
while (1) {
W:
   print \'0\';
   print \'0\';
X:
}
	
Process Q:
while (1) {
Y:
   print \'1\';
   print \'1\';
Z:
}
Synchronization statements can be inserted only at points W, X, Y and Z Which of the following will ensure that the output string never contains a substring of the form 01^n0 or 10^n1 where n is odd?
  • P(S) at W, V(S) at X, P(T) at Y, V(T) at Z, S and T initially 1
  • P(S) at W, V(T) at X, P(T) at Y, V(S) at Z, S and T initially 1
  • P(S) at W, V(S) at X, P(S) at Y, V(S) at Z, S initially 1
  • V(S) at W, V(T) at X, P(S) at Y, P(T) at Z, S and T initially 1

Question 29

Which of the following does not interrupt a running process?
  • A device
  • Timer
  • Scheduler process
  • Power failure

Question 30

Which of the following need not necessarily be saved on a context switch between processes?
  • General purpose registers
  • Translation look aside buffer
  • Program counter
  • All of the above

There are 115 questions to complete.

Last Updated :
Take a part in the ongoing discussion