Question: Question 1 : Mutual Exclusion [ 2 0 marks ] Consider the following program intended to solve the mutual exclusion problem for the case of
Question : Mutual Exclusion marks
Consider the following program intended to solve the mutual exclusion problem for the case of two processes.
beginarrayl
text int mathrmcp
text int mathrmcq
endarray
Process P
while true
P: noncriticalsection;
Pa: if cq
Pb: quadcpmathrm ;
Pc: else cp ;
P: whilecp cq
P: criticalsection;
P: cp ;
end P;
Process Q
while true
Q: noncriticalsection;
Qa: if cp
Qb: q ;
Qc: else cq ;
Q: whilecq cp
Q: criticalsection;
Q: q ;
end Q;
Assuming that each line is atomic, answer the following questions and pay careful attention to the signs of quantities:
i Find an execution of this algorithm that demonstrates that mutual exclusion is not upheld.
ii Now assume that the statements PaPbPc are executed as a single atomic instruction and the same for QaQbQcsee next page Does the program now uphold mutual exclusion? Provide a proof.
Process P
while true
P: noncriticalsection;
P: if cq cp ; else cp ;
P: whilecp cq
P: criticalsection;
P: cp ;
end P;
Process Q
while true
noncriticalsection;
if cp cq ; else cq ;
whilecq cp
criticalsection;
cq ;
end Q;
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
