Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Tutorial 1: Introduction to Concurrency

CSSE7610

The exercises below are from Chapter 2 of M. Ben-Ari Principles of Concurrent and Distributed Programming (second edition), 2006.

1. Consider the following algorithm.

(a) Construct scenarios that write: 012, 002, 02.

(b) Must the value 2 appear in the output?

(c) How many times can the value 2 appear in the output?

(d) How many times can the value 1 appear in the output?

2. Consider the following algorithm.

(a) Construct a scenario in which the loop in p executes exactly once.

(b) Construct a scenario in which the loop in p executes exactly three times.

(c) Construct a scenario in which both loops execute infinitely often.

3. Construct a scenario for the following algorithm in which the final value of n is 2.

4. Consider the following algorithm.

(a) Construct a scenario for which the program terminates.

(b) What are the possible values of n when the program terminates?

(c) Does the program terminate for all scenarios?

(d) Does the program terminate for all fair scenarios?

5. Consider the following algorithm.

(a) Construct a scenario for which the program terminates.

(b) What are the possible values of n when the program terminates?

(c) Does the program terminate for all scenarios?

(d) Does the program terminate for all fair scenarios?