
Solutions to CP W99 Lab2

Started 16h05-16h20 (mostly setup)

NestedMonitor
- the problem is that the DisplayBuffer is a monitor, and calls 
  synchronized methods of Semaphore, which is also a monitor
- simply remove the synchronization in DisplayBuffer
- NB: if synchronization is needed, make sure it does not
  mask accesses to the Semaphore!

ReadersWriters 16h28-17h00 17h20-17h40
- by making the two readers overlap, the writers will starve
- readers and writers try to access the CS by calling methods
  of the ReadWrite interface
- WritersPriorityReadWrite extends SafeReadWrite
- add waitingWriters_ and modify methods
- define subclass PriorityReadersWriters with new makePolicy
- patch HTML
- now the Readers can get starved out!

- Need a hint for fairness!
- HINT: consider a flag to switch writersPriority on & off
- FairReadWrite extends WritersPriorityReadWrite
- readers & writers yield priority when exiting the CS
- define subclass FairReadersWriters with new makePolicy
- patch HTML
- NB: fair assuming writer scheduling is fair!

SingleLaneBridge 17h45-1835
- SafeBridge: synchronize on the number of red/blue cars
- not fair for three cars
- HINT: need to keep track of #waiting cars & whose turn it is
- FairBridge: swap priority each time you get on the bridge

Golf (done afterwards)
- FairGolfClub inherits from GolfClub, overriding buildAllocator()
- FairAllocator extends SimpleAllocator
- make SimpleAllocator.available protected!
- use simple grocery store ticket scheme
- OverTaking allocator taken from the book
