Shared data Bowl of rice (data set) Semaphore chopstick [5] initialized to 1 The structure of Philosopher i: do { wait ( chopstick[i] ); wait ( chopStick[ (i + 1) % 5] ); // eat signal ( chopstick[i] ); signal (chopstick[ (i + 1) % 5] ); // } while (TRUE); Problems with Semaphores Incorrect use of semaphore operations: signal (mutex) l …. wait (mutex)
Shared data Bowl of rice (data set) Semaphore chopstick [5] initialized to 1 The structure of Philosopher i: do { wait ( chopstick[i] ); wait ( chopStick[ (i + 1) % 5] ); // eat signal ( chopstick[i] ); signal (chopstick[ (i + 1) % 5] ); // } while (TRUE); Problems with Semaphores Incorrect use of semaphore operations: l signal (mutex) …. wait (mutex)
OS-UNIT-3.docx