Software 1 - Bitwise operations, fork, & pipes(13)


administrivia

Web Page - http://www.cs.tau.ac.il/~efif/courses/Software1_Spring_04


The Dining Philosophers - the setup

  • Five philosophers are seated around a round table
  • Each philosopher has a bowl of rice in front
  • Between each philosopher and his neighbor is a chopstick
  • Each philosopher thinks for a while, then gets hungry and wants to eat
  • Eating rice requires 2 chopsticks
    • however there are only five chopsticks
    • at most 2 philosophers can be eating at the same time
  • A philosopher may acquire only the chopsticks to his immediate left or right
  • Once a philosopher possesses two chopsticks, he will eat for a while, then put both chopsticks back down on each side
philosophers

The Dining Philosophers - the problem


The Dining Philosophers - the code


Bits and constants


Bitwise operations


Shifting bits


Bitwise operations

practices prev top
Maintained by Efi Fogel. Last modified: June 04 2004.