Consider three concurrent processes P1, P2, and P3 that access a shared…
2021
Consider three concurrent processes P1, P2, and P3 that access a shared variable D initialized to 100:
P1: D = D + 20
P2: D = D + 50
P3: D = D + 10The processes execute on a uniprocessor running a time-shared operating system. If the minimum and maximum possible values of D after all three processes complete are X and Y, respectively, what is Y − X?
Answer: B. 70 — ConceptA read–modify–write statement can be interrupted after reading the shared variable and before writing its computed value. Serial execution accumulates…
- A.
110
- B.
70
- C.
80
- D.
10
- E.
Question not attempted
Attempted by 344 students.
Show answer & explanation
Correct answer: B
Concept
A read–modify–write statement can be interrupted after reading the shared variable and before writing its computed value. Serial execution accumulates every increment, while a delayed stale write can overwrite later updates.
Application
For the maximum, run the three operations without overlap. Then Y = 100 + 20 + 50 + 10 = 180.
For the minimum, let P3 read D = 100 and compute 110, but delay its write. Allow P1 and P2 to complete, and then let P3 write its stale result 110.
Thus X can be 110. It cannot be smaller: every process reads a value at least 100 and adds a positive increment, whose smallest value is 10.
Therefore Y − X = 180 − 110 = 70.
Cross-check
Both bounds are attainable: a serial schedule produces 180, and the delayed P3 write produces 110. The lower-bound argument excludes any final value below 110, so the range is exactly 70.