Question: 1. Consider three processes, P, Q and R with the following code: P: ps1; ps2; ps3; ps4; Q: qs1; qs2; qs3; qs4; R: rs1; rs2;

1. Consider three processes, P, Q and R with the following code:

P: ps1; ps2; ps3; ps4; Q: qs1; qs2; qs3; qs4; R: rs1; rs2; rs3; rs4;

These processes have the following synchronization constraint: a) rs1 must be the first statement to execute b) process R should be the last process to exit c) ps3 must execute after qs2 d) qs3 must execute after ps4 and rs3 e) rs4 must execute after either ps4 or qs4 (or both) have executed

Using semaphores, provide updated codes for P, Q and R that satisfy these constraints.

Can someone please explain why this is the answer?

1. Consider three processes, P, Q and R with the following code:

Problems: [40 Points] 1. Solution: Process P Process Q Process R wait(&s1 ps1> wait(&s1) s1 = 0 s2=0 s3 =-1 S4 0 S5--1 rs1> signal(&s1) signal(&s1 Srs2> ps2> wait(&s2) signal(&s2) wait(&s3) Krs3> signal(&s3) wait(&s4) ps3> ps4> signal(&s3) signal &s4) signal(&s5) wait(&s5) signal(&s4) signal(&s5) 52 Problems: [40 Points] 1. Solution: Process P Process Q Process R wait(&s1 ps1> wait(&s1) s1 = 0 s2=0 s3 =-1 S4 0 S5--1 rs1> signal(&s1) signal(&s1 Srs2> ps2> wait(&s2) signal(&s2) wait(&s3) Krs3> signal(&s3) wait(&s4) ps3> ps4> signal(&s3) signal &s4) signal(&s5) wait(&s5) signal(&s4) signal(&s5) 52

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!