Question: Three processes share a global variable x , and each process ( named P; in a mixed syntax ) performs the following: int k; /

Three processes share a global variable x, and each process (named P; in a mixed syntax) performs the following:
int k; /* local variable */
for (k =0; k 5; k++){
LOAD(x); INCREMENT(x); STORE(x); }
That is, each process executes x++; five times, but each assignment is realized in three steps using its own local register. Now consider the following parallel program:
x =0;
run P(); run P(); run P();
Can the final value of x be as small as 1 or 2? Check possible outcomes using Spin, explain the results, and generalize them.
Hint:
1. Model the three processes and the main (init) program in Prolmela -by implementing the behavior of LOAD, INCREMENT, and STORE using the constructs of Promela (e.g. local variables).
2. Suppose you think x can be 3 but not less. Then you should: a. verify that x==3 is a possible outcome upon termination. - This can be done by asserting that, when only one process (the main process) remains active after three run P(); x cannot be 3.-The number of active processes can be obtained by the _nr_pr special variable or by counting them explicitly. b. Verify that x3 is not a possible outcome upon termination.
 Three processes share a global variable x, and each process (named

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!