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 05:30
Agood flowchart alludes to both the inputs and outputs you will need to receive and give to the user. true or false?
Answers: 3
question
Computers and Technology, 22.06.2019 07:00
You will be given two character arrays of the same size, one will contain a number of ships. ships will move around the character array based on which way they are facing and the route they are on. routes are given in the other array. the route consists of '-' and '|' for straight paths, '\' and '/' for curves, and '+' for intersections. there are ships on these routes. ships always face a direction, '^' for up, '> ' for right, 'v' for down, and '< ' for left. any time the ships hit a '\' or a '/' it will turn as you would expect a ship to turn (e.g. a '^' that moves into a '/' will turn right). at an intersection, ships will always continue straight through. all ships move at the same speed, ships take turns moving and all ships move during one 'tick'. the one in the most top left goes first, followed by those to its right, then the ones in the next row. it iterates along the rows and then down the columns. each ship moves one space on its turn moving along the route. your function needs to return the position of the first collision between two ships and the number of ticks before the crash occurred.
Answers: 2
question
Computers and Technology, 22.06.2019 18:30
Which of the following is an example of intellectual properly! oa. new version of a novelb. journal of ideasc. pages of a bookood. lines of a poem
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
Pl i need the answer now ! which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
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
Chemistry, 23.09.2019 05:50
question
Mathematics, 23.09.2019 05:50
question
Geography, 23.09.2019 05:50
Questions on the website: 13722363