Question: 2 . [ 3 0 points ] Synchronization 1 ) ( 1 5 points ) Suppose that there are n processes wanting to execute a
points Synchronization
points Suppose that there are n processes wanting to execute a critical section. We would like to impose a strict ordering execution of the processes as P P Pn P p Please sketch the code with the use of binary semaphores to enforce the ordering. Hint: the simple solution is that you need n binary semaphores with proper initialization
Process P:
while TRUE
BLANK;
Critical Section
BLANK;
Process P:
while TRUE
BLANK;
Critical Section
BLANK;
Process Pi:
while TRUE
BLANK;
Critical Section
BLANK;
Process Pn:
while TRUE
BLANK;
Critical Section
BLANK;
points In the following code, three processes synchronize with three semaphores L M R to produce output.
Initialize the three binary semaphores
semaphore L ;
semaphore M ;
semaphore R ;
random function return a random float value that is greater than and less than with equal probability
Process
while true
waitL;
printfA;
signalR;
Process
while true
waitR;
printfB;
x random;
if x
signalL;
else
signalM;
Process
while true
waitM;
printfC;
printfD;
x random;
if x
signalL;
else if x
signalR;
Please answer the following questions.
A points What is the minimum length minimum number of characters of output?
B points Is ABABCDBACD a possible output sequence when this set of processes runs? If it is possible, please calculate the probability, if not, explain why.
C points Is ABCDABABCD a possible output sequence when this set of processes runs? If it is possible, please calculate the probability, if not, explain why.
D points What is the probability that exactly two Cs are printed on the screen?
E points What is the probability that exactly two Bs are printed on the screen?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
