Universidad de Costa Rica
Escuela de Ciencias de la Computación e Informática
CI-0122 Sistemas operativos
Ejemplos
|
|
CI0122 /
Ejemplos
|
Synchronization via Monitors
Some monkeys are trying to cross a ravine. A single rope traverses the ravine,
and monkeys can cross hand-over-hand. Up to five monkeys can hang on the rope
at any one time. If there are more than five, then the rope will break and
they will all fall to their end. Also, if eastward-moving monkeys encounter
westward-moving monkeys, all will fall to their end.
a) Write a monitor with two methods WaitUntilSafeToCross(Destionation dst) and
DoneWithCrossing(Destination dst). Where Destination is an enumerator with value EAST=0 or WEST=1.
b) Does your solution suffer from starvation? If so, briefly explain (e.g. give a sequence).
Otherwise, simply state starvation-free. In either, case state your assumptions, if any.