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 16:20
Consider the following statements, then select one of the answers below: the signal() function shown below registers "sig_handler()" as the signal handler function for the sigkill signal, without the complexity of using when the sigkill signal is sent to a process running this code, by a user typing "kill -kill ", where the correct process id is used for to target the process, sig_handler() will be executed.
Answers: 1
question
Computers and Technology, 23.06.2019 10:50
Your friend kayla is starting her own business and asks you whether she should set it up as a p2p network or as a client-server network. list three questions you might ask to kayla decide which network to use and how her answers to those questions would affect your recommendation.
Answers: 2
question
Computers and Technology, 23.06.2019 11:00
This chapter lists many ways in which becoming computer literate is beneficial. think about what your life will be like once you’re started in your career. what areas of computing will be most important for you to understand? how would an understanding of computer hardware and software you in working from home, working with groups in other countries and contributing your talents.
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
Apunishment or the threat of punishment used to enforce conformity. select the best answer from the choices provided t f
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
Spanish, 02.05.2021 14:00
question
Chemistry, 02.05.2021 14:00
Questions on the website: 13722360