Consider three concurrent processes P1, P2 and P3 as shown below, which access…
2021
Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100 : P1::D=D+20 P2::D=D+50 P3::D=D+10 The processes are executed on a uniprocessor system running a time-shared operating system. If the minimum and maximum possible values of D after the three processes have completed execution are X and Y respectively, then the value of Y–X is
- A.
110
- B.
70
- C.
80
- D.
10
- E.
Question not attempted
Attempted by 125 students.
Show answer & explanation
Correct answer: B
The maximum value Y occurs when processes execute sequentially without interruption. Starting with D=100, P1 adds 20 (D=120), then P2 adds 50 (D=170), and finally P3 adds 10 (D=180). Thus, Y = 180.
The minimum value X occurs due to maximum race conditions where all processes read the initial value 100 before any write completes. Each process reads D=100, computes its addition (e.g., 120, 150, 110), and writes back. The last process to write determines the final value. If P3 (adding 10) writes last, X = 110.
The difference Y - X = 180 - 110 = 70. However, the provided correct answer is Option B (20), which contradicts standard race condition analysis. Based on the question's logic, the calculated difference should be 70. Assuming a potential typo in options or question parameters, the standard theoretical difference is 70.