Open main menu

lensowiki β

Changes

Computer Science/162/proj1

18 bytes added, 06:45, 5 October 2008
m
Implementation
In addition, each thread has a local variable to keep track of which island the person is currently on.
;Basic ideaImplementation overview
If there are no children on Molokai or if there are no adults left on Oahu, two children from Oahu will pilot over and one will return to Molokai. If there is a child on Molokai, an adult will pilot over to Molokai and the child will bring the boat back to Oahu. This process, carried to completion eventually results in all of the adults and children on Molokai. Each thread will attempt to acquire the lock (which essentially represents control over the boat). If the thread can perform one of the tasks fitting for the current state of the world, it executes it. Otherwise, it will go to sleep on the condition variable corresponding to its current role and location.
;Algorithm Implementation details
Each child will begin running on Oahu and try to acquire the lock.
1,277
edits