GATE 2008 Computer Science and Information Technology (CS) Questions with Solutions

GATE 2008

185 questions

MCQ 1851-mark 52 · 2-mark 133

Questions 141–145 of 185

Q141Process Synchronization2 marksMCQ−0.67 if wrong
The following is a code with two threads, producer and consumer, that can run in parallel. Further, S and Q are binary semaphores quipped with the standard P and V operations.
 semaphore S = 1, Q = 0; 
integer x;

producer:                   consumer:
while (true) do             while (true) do
    P(S);                       P(Q);
    x = produce ();             consume (x);
    V(Q);                       V(S);
done                        done

Which of the following is TRUE about the program above?

Q142Process Synchronization2 marksMCQ−0.67 if wrong
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 PbP_{b} and VbV_{b} the wait and signal operations on binary semaphores are provided. Two binary semaphores xbx_{b} and yby_{b} 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

Q143Deadlock2 marksMCQ−0.67 if wrong
An operating system implements a policy that requires a process to release all resources before making a request for another resource. Select the TRUE statement from the following:

Q144Deadlock2 marksMCQ−0.67 if wrong
Which of the following is NOT true of deadlock prevention and deadlock avoidance schemes?

Q145CPU Scheduling2 marksMCQ−0.67 if wrong
If the time-slice used in the round-robin scheduling policy is more than the maximum time required to execute any process, then the policy will