protection of two source system with directional relays

Các bài toán đồng bộ

Các bài toán đồng bộ

... mutex = 1; /* Semaphore for the number of waiting customers * This lets the barber go to sleep when there are no customers */ Semaphore customers = 0; /* Number of waiting customers in the barber ... 1; } /* Barber loops within this function */ void barber() { while( ) { /* Go to sleep if there are no customers */ wait( customers ); // protect access to shared variables with semaphore mutex ... variables with semaphore mutex wait( mutex ); /* take customer out of a chair */ waiting_customers -= 1; signal( mutex ); /* cut hair of the current customer */ cut_hair(); /* Let the customer go...

Ngày tải lên: 15/10/2012, 08:57

13 2K 12
w