Concurrency and Synchronization questions

Q50

GATE CS 2016 CS-1Concurrency and SynchronizationMCQ2 marks−2/3 if wrong
Consider the following proposed solution for the critical section problem. There are n processes: P0…Pn−1P_0 \dots P_{n-1}. In the code, function pmax returns an integer not smaller than any of its arguments. For all i, t[i] is initialized to zero.
Code for PiP_i:
do {
    c[i]=1; t[i] = pmax(t[0],...,t[n-1])+1; c[i]=0;
    for every j ≠ i in {0,...,n-1} {
        while (c[j]);
        while (t[j] != 0 && t[j]<=t[i]);
    }
    Critical Section;
    t[i]=0;
    Remainder Section;
} while (true);
Which one of the following is TRUE about the above solution?
Show answer without attempting

Answer: A

Q48

GATE CS 2016 CS-2Concurrency and SynchronizationMCQ2 marks−2/3 if wrong
Consider the following two-process synchronization solution.
Process 0                         Process 1
---------                         ---------
Entry: loop while (turn == 1);    Entry: loop while (turn == 0);
  (critical section)                (critical section)
Exit:  turn = 1;                  Exit:  turn = 0;
The shared variable turn is initialized to zero. Which one of the following is TRUE?
Show answer without attempting

Answer: C

Q49

GATE CS 2016 CS-2Concurrency and SynchronizationNAT2 marks
Consider a non-negative counting semaphore SS. The operation P(S)P(S) decrements SS, and V(S)V(S) increments SS. During an execution, 20 P(S)20\, P(S) operations and 12 V(S)12\, V(S) operations are issued in some order. The largest initial value of SS for which at least one P(S)P(S) operation will remain blocked is _________.
Show answer without attempting

Answer: 7.0

0/30 correct0 marks

Related topics in Operating Systems