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, 21.06.2019 22:30
Ted wants to go out to a neighborhood park and shoot pictures of dew drops on grass. he wants to get a low-level angle of the dew drops. which support equipment should ted use? a. mini tripod b. pistol grip c. monopod d. body mount
Answers: 2
question
Computers and Technology, 22.06.2019 09:30
My mom and i are moving and we don’t have wifi for the next week, i want to know if using a using a hotspot with unlimited data is better than using regular wifi. i’m considering cost, speed, and data sacrifices.
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
What side length would you specify if you were required to create a regular hexagonal plate that was composed of 33 cm(squared) of sheet metal? dimension the side length to 0.1 cm
Answers: 2
question
Computers and Technology, 22.06.2019 22:30
Write a full class definition for a class named player , and containing the following members: a data member name of type string .a data member score of type int .a member function called setname that accepts a parameter and assigns it to name . the function returns no value.a member function called setscore that accepts a parameter and assigns it to score . the function returns no value.a member function called getname that accepts no parameters and returns the value of name .a member function called getscore that accepts no parameters and returns the value of score .this is what i have, aparently this is wrong: class player{private: string name; int score; public: void player: : setname (string n){name =n; }void player: : setscore (int s){score = s; }string player: : getname (){return name; }int player: : getscore (){return score; }};
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, 25.09.2020 01:01
question
Advanced Placement (AP), 25.09.2020 01:01
question
Mathematics, 25.09.2020 01:01
question
Mathematics, 25.09.2020 01:01