2019329621250-迟海滢-Homework-6 Version 0 |
|
👤 Author: by 2990994011qqcom 2021-10-29 07:17:32 last modified by 2990994011qqcom |
The bank provides a service window and 10 seats for customers to wait. When the customer arrives at the bank, if there is a free seat, he will pick up a number at the number machine and wait for the number to be called. Only one customer is allowed to use the number picking machine at a time. When the salesperson is free, he calls a customer to serve him.
semaphore empty = 10
semaphore mutex = 1
semaphore full = 0
semaphore service = 0
customer
{
wait(empty)
wait(mutex)
signal(mutex)
signal(full)
wait(service)
}
Salesperson
{
while(true)
{
wait(full)
signal(empty)
signal(service)
}
}