Jul 14, 2024
chopstick[5]
initialized to 1
wait(chopstick[i])
and wait(chopstick[(i+1) % 5])
to pick up forks
(i+1) % 5
: Handle circular arrangement, especially for the last philosophersignal(chopstick[i])
and signal(chopstick[(i+1) % 5])
to release forksEnd of Lecture