
UCF
School of computer Science
COT 4020: Programming Languages
Fall 2006
Homework 2 (jBACI)
Due on Friday, April 14th by 11:59pm
Instructions
1. Use jBACI to implement the classic producer / consumer
synchronization problem.
2. Your code should support one producer and two or more consumers.
3. The producer and consumers should share a data buffer of size 10 ints .
4. Use binary semaphores to provide mutually exclusive access to the shared
buffer.
5. The following links provide some information / example code for the
producer / consumer problem.
a. http://nob.cs.ucdavis.edu/classes/ecs150-1999-02/Pdf/sync-
problems.pdf
b. http://cs.gmu.edu/cne/modules/ipc/aqua/producer.html
c.
http://java.sun.com/docs/books/tutorial/essential/threads/synchronizati
on.html
d. http://simpy.sourceforge.net/producer_consumer.htm
6. Use jBACI to implement the classic readers / writers problem using
monitors.
7. Your code should support multiple readers and writers. It should take 2 input
arguments which allow the user to specify the number of concurrent readers
and writers.
8. Use monitors to provide mutually exclusive access to the resource.
9. Multiple readers should be able to concurrently access the resource, however,
only one writer at a time should be allowed access.
10. Your solution should avoide both deadlock and starvation of writers.
11. The following links provide some information / example code for the readers /