关于操作系统信号量的作业题

The Sleeping-Barber Problem:
-A barbershop consists of a waiting room with n chairs and the barber room containing the barber chair.
-If there are no customers to be served, the barber goes to sleep.
-If a customer enters the barbershop and all chairs are occupied, then the customer leaves the shop.
-If the barber is busy but chairs are available, then the customer sits in one of the free chairs.
-If the barber is asleep, the customer wakes up the barber.
Write a program to coordinate the barber and the customers using semaphores.

答案如下:
Barber:
do
{
Wait(Scuthair);//检查是否有顾客,无,就睡眠
给某个顾客理发
}while(1);
Customer i:
Wait(Snumchair);//申请占用椅子signal(Scuthair);//给理发师发一个信号
坐在椅子上等着理发//共享变量
Semaphore Scuthair,Mutexchair;//Scuthair给理发师,Mutexchair制约顾客对椅子的互斥占领
Int number=0;//顾客的共享变量,记录已经有的顾客数
Scuthair = 0;Mutexchair=1;
Customer i:
Wait(Mutexchair);//申请对共享变量number的操作(申请占用椅子)
If(number == n-1)
{
Signal(Mutexchair);
Exit;
}
Number = number +1;
Signal(Scuthair);//给理发师发一个信号
Signal(Mutexchair);
等待理发
理发完毕
Wait(Mutexchair);//申请对共享变量number的操作
Number=number-1;
Signal(Mutexchair);
离开理发店

请问 If(number == n-1)
{
Signal(Mutexchair);
Exit;
}这一步怎么理解?
尤其是number == n-1 是怎么回事,求大神帮助!

椅子数量是有限的,理发完毕以后你必须说明:“我要走了”,这样已经才能空出来,number记录已经有的顾客数量,如果你走的时候不对它-1,操作系统以为你还在,别的顾客也进不来