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 + 10

The 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. 70ConceptA read–modify–write statement can be interrupted after reading the shared variable and before writing its computed value. Serial execution accumulates…

  1. A.

    110

  2. B.

    70

  3. C.

    80

  4. D.

    10

  5. 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

  1. For the maximum, run the three operations without overlap. Then Y = 100 + 20 + 50 + 10 = 180.

  2. 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.

  3. 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.

  4. 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.

Explore the full course: Up Lt Grade Assistant Teacher 2025

Loading lesson…