






































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







































Computer Science, CU-Boulder
Last Update: 02/21/
Quiz: Write a synchronization schema for the problem
philosopher(int i) {
while(TRUE) {
// Think // Eat P(fork[i]);
P(fork[(i+1) mod 5]);
eat(); V(fork[(i+1) mod 5]); V(fork[i]); } } semaphore fork[5] = (1,1,1,1,1);
philosopher(int i) {
while(TRUE) {
// Think // Eat P(mutex);
P(fork[i]); P(fork[(i+1) mod 5]); V(mutex);
eat(); V(fork[(i+1) mod 5]); V(fork[i]); } } semaphore fork[5] = (1,1,1,1,1); semaphore mutex = 1;
philosopher(int i) {
while(TRUE) {
// Think // Eat j = i % 2; P(fork[(i+j) mod 5]);
P(fork[(i+1-j) mod 5]);
eat(); V(fork[(i+1-j) mod 5]); V(fork[[(i+j) mod 5]); } } semaphore fork[5] = (1,1,1,1,1);
2
philosophers problem.
simultaneous
)n
raised
by one process (or hardware) to call
another process’s attention to an event – It can be
caught
(or ignored) by the subject
process
delete
key