Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

OPERATING SYSTEM [SHOW IN DETAILS IN STEP BY STEP] SEMAPHORE Following is the solution of the Producer-consumer problem using semaphores. Producers produce new items and

OPERATING SYSTEM [SHOW IN DETAILS IN STEP BY STEP]

SEMAPHORE

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

Following is the solution of the Producer-consumer problem using semaphores. Producers produce new items and put those items in the buffer, where Consumers consume items from the buffer and empty the buffer. 3 semaphores have been used in this solution - mutex, countEmpty, and countFull. procedure producer() { while(true) { item = producedItem(); wait (countEmpty); wait (mutex); putintoBuffer(item); signal (mutex); signal (count Full); } procedure consumer() { while (true) { wait (count Full); wait (mutex); item = removeFromBuffer(); signal (mutex); signal (count Empty); consume Item(item); } The definition of wait and signal function of semaphores are given below. Definition of wait(): Definition of signal(): wait(semaphore *s) { S-> value-- if (S-> value list; block; ) signal(semaphore *s) { S->value++; if (S->value list; wakeup(P); } problem 0 points possible (ungraded, results hidden) Suppose, there are three producers P1, P2, and P3 who want to produce and put items in the buffer. And, there are four consumers C1, C2, C3, and C4 who want to consume items from the buffer. No process takes more than 5 units of time to complete unless the process goes to the waiting queue(s- >list) of semaphore. At a certain point of the execution, following are the values of the semaphores: mutex=1, countEmpty=8, countFull=2 Find the output of the following sequence of commands. At time 0:01 started At time 0: C2 started At time 10: C3 started Value of countEmpty: Value of countFull: Processes in the waiting queue of the semaphore: [Write process names with Capital letter, For example: P7. If there are multiple process writes their names using comma, For example: P6,P7. If there is no process in the semaphore's list, write EMPTY in the box] At time 15: P1 started At time 20: P2 started Value of countEmpty: Value of countFull: Processes in the waiting queue of the semaphore: [Write process names with Capital letter, For example: P7. If there are multiple process writes their names using comma, For example: P6,P7. If there is no process in the semaphore's list, write EMPTY in the box] At time 25: C4 started At time 30 : P3 started Value of countEmpty: Value of countFull: Processes in the waiting queue of the semaphore: [Write process names with Capital letter, For example: P7. If there are multiple process writes their names using comma, For example: P6,P7. If there is no process in the semaphore's list, write EMPTY in the box] Submit You have used 0 of 2 attempts Save

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

Question

What problems can be solved by genetic algorithms?

Answered: 1 week ago

Question

Solve: 3x = 6 O X= O x = 21 = Ox=

Answered: 1 week ago