|
CS2403: Operating Systems PrinciplesAssignment #3Due: Monday, July 31 @ 2:45 p.m.
|
| Assignment Questions |
| var customers: semaphore; | // # of customers waiting for service |
| var barbers: semaphore; | // # of barbers waiting for customers |
| var mutex: semaphore; | // for mutual exclusion |
| var waiting: int; | // customers waiting (not being cut) |
| var chairs: int; | // # of chairs for waiting |
| customers:= 0; |
| barbers:= 0; |
| mutex:= 1; |
| waiting:= 0; |
| chairs:= 5; |
| repeat | ||
| waiting:= waiting - 1; | // decrement count of waiting customers | |
| cut_hair(); | // cut the customer's hair | |
| until false; | ||
| if (waiting < chairs) | |||
| then begin | |||
| waiting:= waiting + 1; | |||
| get_haircut(); | // get a haircut | ||
| end | |||
| else |
This document can be found at http://www.cs.unb.ca/~nwebber/CS2403/assignments/assignment3.html
Last updated July 27, 2000 by Natalie Webber.
Contact Natalie at nwebber@unb.ca