Computer Science, asked by ushruthy, 11 months ago

Consider four concurrent processes P1, P2, P3 and P4 as shown below, which access a shared variable V that has been initialized to 200.
V = V + 30
V = V - 60​
V = V + 40
V = V + 20
The process are executed on a single processor system running a ti,e shared operating system. If minimum ans maximum possible values of V after the four processes have completed equation are x and y respectively, then the value of y-x?

Answers

Answered by namanchauhan8998
26

Answer:

100

Explanation:

Answered by ankurbadani84
1

Answer:

150

Explanation:

Let us assume process reading below statements.

P1 - V = V + 30

P2 - V = V - 60​

P3 - V = V + 40

P4 - V = V + 20

P2 reads V = 200, preempted.

P1 executes V = V+20, V = 220.

P3 executes V =V+40, V=260.

P4 executes V =V+20, V=280.

Now, P2 has V= 200, executes

V = V - 60 = 200- 60 = 140

P2 writes V=140 final value. This is minimum. This is x.

P2 reads V = 200, executes V = V - 60, before that assume P1, P3 & P4 has read V=200.

P2 makes V = 200 - 60 = 140 & writes it.

P1 executes (V = 200), V =V + 30 = 230 , P3 executes V = V + 40 = 270 P4 executes V = V +20 = 290 gives maximum value V = 290.  This is y.

So, Y - X = 290 - 140 = 150.

Similar questions