Concurrency and Synchronization questions

Q34

GATE CS 2013 CSConcurrency and SynchronizationMCQ2 marks−2/3 if wrong
A shared variable xx, initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X reads xx from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads xx from memory, decrements by two, stores it to memory, and then terminates. Each process before reading xx invokes the PP operation (i.e., wait) on a counting semaphore SS and invokes the VV operation (i.e., signal) on the semaphore SS after storing xx to memory. Semaphore SS is initialized to two. What is the maximum possible value of xx after all processes complete execution?
Show answer without attempting

Answer: D

Q39

GATE CS 2013 CSConcurrency and SynchronizationMCQ2 marks−2/3 if wrong
A certain computation generates two arrays aa and bb such that a[i]=f(i)a[i]=f(i) for 0≤i<n0 \le i < n and b[i]=g(a[i])b[i] = g(a[i]) for 0≤i<n0 \le i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array aa and Y computes the array bb. The processes employ two binary semaphores RR and SS, both initialized to zero. The array aa is shared by the two processes. The structures of the processes are shown below.
Process X:
private i;
for (i=0; i<n; i++) {
  a[i] = f(i);
  ExitX(R, S);
}

Process Y:
private i;
for (i=0; i<n; i++) {
  EntryY(R, S);
  b[i] = g(a[i]);
}
Which one of the following represents the CORRECT implementations of ExitX and EntryY?
Show answer without attempting

Answer: C

0/20 correct0 marks

Related topics in Operating Systems