OSF DCE Application Development Guide--Core Components
OSF DCE Application Development Guide—Core Components
You can think of threads as executing simultaneously, regardless of the number of
processors present. You cannot make any assumptions about the start or finish times
of threads or the sequence in which they execute, unless explicitly synchronized.
• Shared Resources
An advantage of using multiple threads over using separate processes is that the
former share a single address space, all open files, and other resources.
• Potential Simplicity
Multiple threads can reduce the complexity of some applications that are inherently
suited for threads.
6.2 Software Models for Multithreaded Programming
The following subsections describe four software models for which multithreaded
programming is especially well suited:
• Boss/worker model
• Work crew model
• Pipelining model
• Combinations of models
6.2.1 Boss/Worker Model
In a boss/worker model of program design, one thread functions as the boss because it
assigns tasks to worker threads. Each worker performs a different type of task until it is
finished, at which point the worker interrupts the boss to indicate that it is ready to
receive another task. Alternatively, the boss polls workers periodically to see whether or
not each worker is ready to receive another task.
A variation of the boss/worker model is the work queue model. The boss places tasks in
a queue, and workers check the queue and take tasks to perform. An example of the
work queue model in an office environment is a secretarial typing pool. The office
manager puts documents to be typed in a basket, and typists take documents from the
basket to work on.
6.2.2 Work Crew Model
In the work crew model, multiple threads work together on a single task. The task is
divided into pieces that are performed in parallel, and each thread performs one piece.
An example of a work crew is a group of people cleaning a house. Each person cleans
6− 2 Tandem Computers Incorporated 124245