
H8: Active Objects and Monitors
CSE 335, Spring 2009
Due by Tuesday, April 14 at 11:59 p.m.
Objectives
1. Learn about how to synchronize threads.
2. Learn about the active object and monitor patterns (not covered in the design patterns book).
3. Gain experience drawing sequence diagrams representing multithreaded interactions.
4. Gain experience with the ACE toolkit.
Description
For this homework, you will be comprehending a multithreaded program that involves producer
and consumer threads interacting over a shared buffer. The producers and consumers produce and
consume lines of text (i.e., strings), respectively. They are implemented as active objects. The
producers pass lines to the consumers through the shared buffer, which is implemented as a monitor.
Figure 1depicts the design of the program.
The sources for this program are available in /user/cse335/S09/H8-src. For this assignment,
you will examine the program to comprehend how the producer and consumer threads use the
mechanisms that we have discussed in class (i.e., mutexes and condition variables) to synchronize.
Then, you will create a sequence diagram representing a specific scenario of interaction.
Tasks
1. Copy the files into your workspace. We will not be using svn for this assignment.
1 1
<<monitor>>
...
2 2
LineProducer LineConsumer
BoundedLineBuffer
putLine(id : int, line : string)
getLine(id : int) : string
...
Figure 1: Design of producer-consumer program.
1