Question: Consider the following processes P1 and P2 that update the value of the shared variables, x and y, as follows: Assume that the initial values

Consider the following processes P1 and P2 that update the value of the shared variables, x and y, as follows:

Process P1 : (performs the operations: X :=x * y y ++

Assume that the initial values of x and y are 2 and 3 respectively. P1 enters the system first and so it is required that the output is equivalent to a serial execution of P1 followed by P2. The scheduler in the uniprocessor system implements a pseudo-parallel execution of these two concurrent processes by interleaving their instructions without restricting the order of the interleaving.
a. If the processes P1 and P2 had executed serially, what would the values of x and y have been after the execution of both processes?
b. Write an interleaved concurrent schedule that gives the same output as a serial schedule.
c. Write an interleaved concurrent schedule that gives an output that is different from that of a serial schedule.

Process P1 : (performs the operations: X :=x * y y ++ ) LOAD R1, X LOAD R2, Y MUL R1, R2 STORE X, R1 INC R2 STORE Y, R2 Process P2 : (performs the operations: x ++ * y = x ) LOAD R3, X INC R3 LOAD R4, Y MUL R4, R3 STORE X, R3 STORE Y, R4

Step by Step Solution

3.43 Rating (169 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a P1 and P2 are executed serially Initially x2 and y3 P1 multiplies x and y and assigns the result t... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Operating Systems Internals And Design Principles Questions!