Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 10 and 0.Two threads execute the following statements (in mixed syntax):
Thread 1: while (x != y){ x = x -1; y = y +1; }
Thread 2: await (x == y); atomic { x =8; y =2; }
Like in Promela, each assignment is an atomic action. Write a Promela model that captures the behavior of this system and
1. Use Spin to check if both threads always terminate, and to show what the final values of x and y can be.
2. Explain what happens if the two assignments in Thread 2 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 (x1, y1) and (x2, y2). Then you need to verify three things:
1.(x1, y1) is a possible outcome.
2.(x2, y2) is a possible outcome.
3. Any pair of values other than (x1, y1) and (x2, y2) are not possible.

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

Explain why a mirror cannot give rise to chromatic aberration.

Answered: 1 week ago