Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sleeping Barber Problem. Fill out the 7 tables on the right after each semaphore and then answer the questions as the bottom. 1. How many

Sleeping Barber Problem. Fill out the 7 tables on the right after each semaphore and then answer the questions as the bottom.

image text in transcribed

1. How many people/processes were involved with the barbershop?

2. How many people were completely done getting a haircut at the end of the code stepthrough?

3. How many people were still waiting to get their hair cut?

4. How many people walked out? (Why?)

BR AZWRS A2WRS |Queue BR Queue CR Queue NFWRS Barber 1 Barber 2 Customer 1 Customer 2 Customer 3 Customer 4 sem Wait(A2WRS) semwait(A2WRS) sem Wait(CR) if(NFWRS>0) NFWRS -= 1; semSignal(CR) sem Wait(A2WRS) semWait(A2WRS) semSignal(A2WRS) if(NFWRS>0) NFWRS -= 1; sem Signal(CR) semSignal(A2WRS) if(NFWRS>0) NFWRS -= 1; semSignal(A2WRS) NFWRS+=1 sem Signal(BR) semSignal(A2WRS) sem Wait(A2WRS) if(NFWRS>0) NFWRS -= 1; semSignal(CR) semSignal(A2WRS) 20 21 semWait(CR) 22 sem Wait(A2WRS) 23 NFWRS+=1 24 semSignal(BR) 25 semSignal(A2WRS) sem Wait(BR) 26 27 sem Wait(BR) BR AZWRS A2WRS |Queue BR Queue CR Queue NFWRS Barber 1 Barber 2 Customer 1 Customer 2 Customer 3 Customer 4 sem Wait(A2WRS) semwait(A2WRS) sem Wait(CR) if(NFWRS>0) NFWRS -= 1; semSignal(CR) sem Wait(A2WRS) semWait(A2WRS) semSignal(A2WRS) if(NFWRS>0) NFWRS -= 1; sem Signal(CR) semSignal(A2WRS) if(NFWRS>0) NFWRS -= 1; semSignal(A2WRS) NFWRS+=1 sem Signal(BR) semSignal(A2WRS) sem Wait(A2WRS) if(NFWRS>0) NFWRS -= 1; semSignal(CR) semSignal(A2WRS) 20 21 semWait(CR) 22 sem Wait(A2WRS) 23 NFWRS+=1 24 semSignal(BR) 25 semSignal(A2WRS) sem Wait(BR) 26 27 sem Wait(BR)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

ISBN: 0262660709, 978-0262660709

More Books

Students also viewed these Databases questions

Question

l Define diversity management, and discuss what it encompasses.

Answered: 1 week ago

Question

7-16 Compare Web 2.0 and Web 3.0.

Answered: 1 week ago