subject

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);
read(x); read(x); read(x); read(x);
x = x - 2; x = x - 3; x = x + 2; x = x + 3;
write(x); write(x); write(x); write(x);
semSignal(s); semSignal(s); semSignal(s); semSignal(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 x after 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 x after all 4 processes complete execution? Show how this value would be achieved and the order of execution necessary for this to occur.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:00
The fourth generation of computers emerged between 1970s and 1980s. which technological advancement brought about this generation of computers? which computer architecture was used most in this generation?
Answers: 3
question
Computers and Technology, 23.06.2019 20:30
If chris has a car liability insurance, what damage would he be covered for
Answers: 1
question
Computers and Technology, 23.06.2019 21:20
In microsoft word, when you highlight existing text you want to replace, you're in              a.  advanced mode.    b.  automatic mode.    c.  basic mode.    d.  typeover mode
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
Hazel has just finished adding pictures to her holiday newsletter. she decides to crop an image. what is cropping an image?
Answers: 1
You know the right answer?
Assume there is a shared variable x, initialized to 0, that is operated on by four concurrently exec...
Questions
question
Mathematics, 10.04.2020 23:51
question
Mathematics, 10.04.2020 23:51
Questions on the website: 13722367