Operating Systems | Process Management | Question 6
A shared variable x, initialized to zero, 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. What is the maximum possible value of x after all processes complete execution? (GATE CS 2013)
(A) -2
(B) -1
(C) 1
(D) 2
Answer: (D)
Explanation: See http://quiz.geeksforgeeks.org/operating-systems-process-management-question-11/ for explanation.
Quiz of this Question
Recommended Posts:
- Operating Systems | Process Management | Question 6
- Operating Systems | Process Management | Question 6
- Operating Systems | Process Management | Question 6
- Operating Systems | Process Management | Question 6
- Operating Systems | Memory Management | Question 6
- Operating Systems | Memory Management | Question 10
- Operating Systems | Memory Management | Question 2
- Operating Systems | Memory Management | Question 10
- Operating Systems | Memory Management | Question 8
- Operating Systems | Memory Management | Question 10
- Operating Systems | Memory Management | Question 4
- Operating Systems | Memory Management | Question 9
- Operating Systems | Memory Management | Question 5
- Operating Systems | Process Synchronization | Question 5
- Operating Systems | Input Output Systems | Question 5



