Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100. P1 P2 P3 : : D =

295 views
in Computer
closed

Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100.

 P1 P2 P3 : : D = D + 20 : : : : D = D - 50 : : : : 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 __________.

by (30.0k points)
selected by

Maximum value (Y):

• Process P1 reads the initial value 100 during execution P1 will update the value of D to (100 + 20 = 120) and writes it to memory.
• P2 and P3 read the value 120 from the memory.
• P2 will get executed before P1 and write the value (120 - 50 = 70) to memory. Since P3 is holding D = 120 after its execution D will be equal to (120 + 10 = 130) ∴ Y = 130

Minimum value (X):

• P1, P2 and P3 read the value 100 from the memory
• P1 will execute first, after its execution it will update (D = 100 + 20 = 120)
• After P1, P3 will execute and it will update the value to (D = 100 + 10 = 110)
• Finally, P2 will be execute and D will be equal to 100 - 50 = 50 ∴ X = 50
• Y - X = 130 - 50 = 80