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 07:00
Robots with telescoping arms are sometimes used to perform tasks (e.g., welding or placing screws) where access may be difficult for other robotic types. during a test run, a robot arm is programmed to extend according to the relationship r = 3 + 0.5cos(4θ) and the arm rotates according to the relationship θ=−π4t2+πt , where r is in feet, θ is in radians, and t is in seconds. use a computer program to plot the path of tip a in x and y coordinates for 0 ≤ t ≤ 4s.
Answers: 2
question
Computers and Technology, 22.06.2019 07:00
For all machines-not just hammers- the user applies force force to the machine to the machine over a certain distance. a. input b. output c. duo d. none of the above
Answers: 1
question
Computers and Technology, 22.06.2019 07:00
Our primary purpouse as electricians is to do wich of the following core concepts? a: install electrical components in a way they can be upgraded b: install electrical equiptment in a way that reduces heat c: install electrical systems in a safe manner d: only b and c
Answers: 1
question
Computers and Technology, 22.06.2019 10:00
What is a society that has moved to the internet rather than relying on physical media called
Answers: 2
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, 16.06.2021 05:30
question
Mathematics, 16.06.2021 05:30
question
Mathematics, 16.06.2021 05:30
question
Mathematics, 16.06.2021 05:30
question
Mathematics, 16.06.2021 05:30
Questions on the website: 13722359