Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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?

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions