OSF DCE Application Development Guide--Core Components

OSF DCE Application Development Guide—Core Components
6.2.4 Combinations of Models
You may find it appropriate to combine the software models in a single program if your
task is complex. For example, a program could be designed using the pipelining model,
but one or more steps could be handled by a work crew. In addition, tasks could be
assigned to a work crew by taking a task from a work queue and deciding (based on the
task characteristics) which threads are needed for the work crew.
6.3 Potential Disadvantages of Multithreaded Programming
When you design and code a multithreaded program, consider the following problems
and accommodate or eliminate each problem as appropriate:
Potential Complexity
The level of expertise required for designing, coding, and maintaining multithreaded
programs may be higher than for most single-threaded programs because
multithreaded programs may need shared access to resources, mutexes, and condition
variables. Weigh the potential benefits against the complexity and its associated
risks.
Nonreentrant Software
If a thread calls a routine or library that is not reentrant, use the global locking
mechanism to prevent the nonreentrant routines from modifying a variable that
another thread modifies. Chapter 8 discusses nonreentrant software in more detail.
Note: A multithreaded program must be reentrant; that is, it must allow
multiple threads to execute at the same time. Therefore, be sure that
your compiler generates reentrant code before you do any design or
coding work for multithreading. (Many C, Ada, Pascal, and BLISS
compilers generate reentrant code by default.)
If your program is nonreentrant, any thread synchronization techniques
that you use are not guaranteed to be effective.
Priority Inversion
Priority inversion prevents high-priority threads from executing when
interdependencies exist among three or more threads. Chapter 8 discusses priority
inversion in more detail.
Race Conditions
A type of programming error called a race condition causes unpredictable and
erroneous program behavior. Chapter 8 discusses race conditions in more detail.
Deadlocks
A type of programming error called a deadlock causes two or more threads to be
blocked from executing. Chapter 8 discusses deadlocks in more detail.
6 4 Tandem Computers Incorporated 124245