6.11 Version 0 |
|
👤 Author: by wsj2014329620063 2016-11-17 18:20:12 |
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<pthread.h>
#include<semaphore.h>
#include<fcntl.h>
#include<errno.h>
#define n 5 //the shop have five chairs
//design three semaphores: mutex,customer,barbers
sem_t mutex,customers,barbers;
int waiting=0; //the number of waiting customers
int chair[5];
void * barber();
void * customer(void *arg);
&nbs