1. Computer Science 531
Assignment #3
Due: Tuesday, Nov. 4
150 points
A group of M fraternity brothers and sorority sisters is having a party and drinking from a keg
that can hold 100 servings of beverage. One unlucky pledge is responsible for replacing the keg
each time it empties. When a partier wants to drink, he or she fills a cup from the keg, unless it
is empty. If the keg is empty, the partier wakes up the pledge and then waits until the pledge has
returned with a new keg. The behavior of the partiers and pledge is specified by the following
'threads':
Partier:
loop
tellPledgeIfKeglsEmpty
getServingFromKeg
drink
waitSomeAmountOfTime
end loop
Pledge:
loop
waitForKegloEmpty
getNewKeg
end loop
1)Develop a Java monitor or Ada protected record which implements the actions of a
semaphore.
2)Write a solution to the above program using that semaphore implementation for
synchronization. Your Java or Ada solution should have a single command-line argument
representing the number of partiers.
3)Write a solution to the above program without using the semaphore implementation. This
program can use a separate class or protected record for synchronization but it should be
one especially developed for the program (rather than a generic semaphore). It should not
be exactly equivalent to the solution of 2). Again, use a single command-line argument
representing the number of partiers.