What is the maximum possible value of xafter all 4 processes complete execution? Show how this value would be achieved and the order of execution necessary for this to occur. b) What is the minimum possible value of xafter all 4 processes complete execution? Show how this value would be achieved and the order of execution necessary for this to occur.
Shared Variable Problem. Assume there is a shared variable x, initialized to 0, that is operated on by four concurrently executing processes (A, B, C, and D) as shown below:
Process A |
Process B |
Process C |
Process D |
semWait(s); |
semWait(s); |
semWait(s); |
semWait(s); |
Note that each process, before reading x, invokes the semWait operation on a counting semaphore s and invokes the semSignal operation on the semaphore s after writing x. The counting semaphore s is initialized to a value of 2. The processes can arrive in any order and can be preempted at any point in their execution by another process. Answer the following questions:
- a) What is the maximum possible value of xafter all 4 processes complete execution? Show how this value would be achieved and the order of execution necessary for this to occur.
- b) What is the minimum possible value of xafter all 4 processes complete execution? Show how this value would be achieved and the order of execution necessary for this to occur.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps