Week 9

Assignment 4: Dining Java Philosophers

  • Assigned: Mon, Oct 19
  • Due: Fri, Oct 30
  • Questions?

Notes

  • Ben-Ari slides: PDF
  • My monitor notes: PDF
  • Monitor state transition diagram: PDF

Class participation with monitors:

  • The One-Lane Bridge problem:
    Cars coming from the north and south arrive at a 
    one-lane bridge. Cars heading in the same direction 
    can cross the bridge at the same time, but cars 
    heading in opposite directions cannot.
  • can we find a way to be safe, fair, and efficient?
  • handout: PDF (with thanks to Charlie Hughes!)
  • Demo and codewalk of csp-dining-philosophers.go
    • Go language features highlighted:
      • channels
      • select
    • Design basis for solution in Go: go routines (processes)
      • room (communicates with philosophers over channels)
        • for philosophers to enter/leave – at most 4 at a time to prevent deadlocking, 5th philosopher blocks
      • forks (communicate with philosophers over channels)
      • philosophers (communicate with forks over channels)