Q34
A shared variable , initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X reads from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads from memory, decrements by two, stores it to memory, and then terminates. Each process before reading invokes the operation (i.e., wait) on a counting semaphore and invokes the operation (i.e., signal) on the semaphore after storing to memory. Semaphore is initialized to two. What is the maximum possible value of after all processes complete execution?
Show answer without attempting
Answer: D