Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 3: Semaphores In an operating system, processes can run concurrently. Sometimes we need to impose a specific order in execution of a set of

image text in transcribed

Question 3: Semaphores In an operating system, processes can run concurrently. Sometimes we need to impose a specific order in execution of a set of processes. We represent the execution order for a set of processes using a process execution diagram. Consider the following process execution diagram. The diagram indicates that Prl must terminate before Pr2, Pr3 and Pr4 start execution. It also indicates that Pr4 should start after Pr2 and Pr3 terminate and Pr2 and Pr3 can run Pr3 Pr1 Pr4 Pr2 The process execution diagram can also be represented using Serial and Parallel notation. The above execution diagram is represented as Serial(P1, Parallel(P2, P3), P4) We can use semaphores in order to enforce the execution order. Semaphores have two operations as explained below P(or wait) is used to acquire a resource. It waits for semaphore to become positive, then decrements it by . V(or signal) is used to release a resource It increments the semaphore by 1, waking up a blocked processes, if any We can use the following semaphores to enforce the execution order above: Pri: body; V(sl); Vsl); Pr2: Pisl): body; V(s2); Pr3: P(sl); body; V(s3): Pr4: P(s2): P(s3); body: This assume that the semaphores s1, s2, and s3 are created with an initial value of O before processes Pr1, Pr2, Pr3, and Pr4 execute. Based on these definitions explanation, answer the questions about the following process execution graph. Pr3 Pr5 Pr4 Pr1 Pr6 5pts] a) Represent the process execution diagram using the Serial and Parallel notation. [20pts] b) Use the semaphores s1,2,s3,s4 to enforce the execution order according to the process execution diagram. Assume the following initialization values for s1,s2,s3,s4: (No points breakdown is provided for this question)

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