6.11_2013329620033//它干掉了我的空格!! Version 0 |
|
👤 Author: by 2013329620033yellow 2015-10-28 08:46:44 |
semaphore mutex,waiting,baber_sleep;
boolean new_customer; //whether there is a new customer or not
int num_customer; //number of customer
boolean run(void){
if (num_customer>0){return true;} //still has customer
else return false;
}
do{
do{
wait(mutex);
if(new_customer){ //comes a new customer
num_customer++;
if(num_customer>n) //leave
num_customer--;
if(num_customer>1&&num_customer<=n) //wait
signal(waiting)