Question: Two global int variables, x and y , are initialized to 1 0 and 0 . Two threads execute the following statements ( in mixed
Two global int variables, x and y are initialized to and Two threads execute the following statements in mixed syntax:
Thread : while x y x x ; y y ;
Thread : await x y; atomic x ; y ;
Like in Promela, each assignment is an atomic action. Write a Promela model that captures the behavior of this system and
Use Spin to check if both threads always terminate, and to show what the final values of x and y can be
Explain what happens if the two assignments in Thread are not done atomically, and confirm your explanation using Spin.
Note: There may or may not be two or more final values.
Hint: Suppose you think that the possible final values are x y and x y Then you need to verify three things:
x y is a possible outcome.
x y is a possible outcome.
Any pair of values other than x y and x y are not possible.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
