Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following program segments for two different processes (P1, P2) exe

ID: 3826567 • Letter: C

Question

Consider the following program segments for two different processes (P1, P2) executing concurrently and where B and A are not shared variables, but X starts at zero as a shared variable. P1 DO A = 1, 5 X =X - 1
ENDDO P2 DO B = 1, 4 X =X +1 ENDDO If the processes P1 and P2 execute concurrently once at any speed, what are the possible resulting final values of x? Explain your answers. Consider the following program segments for two different processes (P1, P2) executing concurrently and where B and A are not shared variables, but X starts at zero as a shared variable. P1 DO A = 1, 5 X =X - 1
ENDDO P2 DO B = 1, 4 X =X +1 ENDDO If the processes P1 and P2 execute concurrently once at any speed, what are the possible resulting final values of x? Explain your answers. Consider the following program segments for two different processes (P1, P2) executing concurrently and where B and A are not shared variables, but X starts at zero as a shared variable. P1 DO A = 1, 5 X =X - 1
ENDDO P2 DO B = 1, 4 X =X +1 ENDDO If the processes P1 and P2 execute concurrently once at any speed, what are the possible resulting final values of x? Explain your answers.

Explanation / Answer

when P1 and P2 execute concurrently once, DO block of P1 and DO block of P2 executed.

Then the value of X will varies in two different block.

In P1 block X=0 (initialy) , So the value of X=X-1 is 1.

In P2 block X=X+1

So X=1+1=2

Similarly the value of X changes during the execution of P1 and P2 processes concurrently

Now when P1 block executed X=1 and when P2 block executed X=2 .

So the value of X are ((0,1),(1,2)....)