ch07 Synchronization Examples - Blankfill
ch07 Synchronization Examples - Blankfill
Chapter 7
Synchronization Examples
int n;
semaphore mutex = 1;
semaphore full = 0;
semaphore empty = n;
while (true) {
wait(full);
wait(mutex);
...
/* remove an item from buffer to next_consumed */
...
signal(mutex);
signal(empty);
...
/* consume the item in next_consumed */
...
}
while (true) {
wait(rw_mutex);
...
/* writing is performed */
...
signal(rw_mutex);
}
DiningPhilosophers.pickup(i);
...
eat
...
DiningPhilosophers.putdown(i);