操作系统实验.pptxVIP

  • 12
  • 0
  • 约2.08千字
  • 约 13页
  • 2020-03-06 发布于上海
  • 举报
The Sleeping-Barber ProblemBarbershop consists of a waiting room with n chairs,and a barber room with one barber chairNo customer, barber goes to sleepIf barber is asleep, new customer wakes up himBarberchairn chairsVar empty, full, mutex: semaphore:=n,0,1;Begin parbegin Customer: begin repeat wait(empty); wait(mutex); find a seat; signal(mutex); signal(full); until false; end parend endBarber: begin repeat wait(full); signal(empty); cutting; until false; endVar int waiting=0; semaphore customers, barber, mutex; customers=0; barber=0; mutex=1;{parbegin Customer: {wait(mutex); if (waiting

文档评论(0)

1亿VIP精品文档

相关文档