Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions