Skip to content
Related Articles

Related Articles

GATE | Quiz for Sudo GATE 2021 | Question 9
  • Last Updated : 14 Dec, 2020

A shared variable x, initialized to one, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X reads x from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads x from memory, decrements by two, stores it to memory, and then terminates. Each process before reading x invokes the P operation (i.e., wait) on a counting semaphore S and invokes the V operation (i.e., signal) on the semaphore S after storing x to memory. Semaphore S is initialized to two. Which of the following set(s) has/have possible value of x after all processes complete execution?

Note – This question is multiple select questions (MSQ).
(A) {-2, -1, 0, 1, 2}
(B) {-3, -2, -1, 0, 1, 2}
(C) {-3, -2, -1, 0, 1, 2, 3}
(D) {-4, -3, -2, -1, 0, 1, 2}

Answer: (A) (B) (D)

Explanation: Minimum possible value = -4
Maximum possible value = 2

So, option (A), (B), and (D) are correct.

Refer – GATE CS 2013 | Question 65

Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Recommended Articles
Page :