MCQ · 2 marks · Concurrency and Synchronization

GATE CS 2013 CS — Q34

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?
Select one option