OSF DCE Application Development Guide--Core Components

Chapter 6. Introduction to Multithreaded
Programming
DCE Threads is a user-level (nonkernel) threads package based on the pthreads interface
specified by POSIX in 1003.4a, Draft 4. This chapter introduces multithreaded
programming, which is the division of a program into multiple threads (parts) that
execute concurrently. In addition, this chapter describes four software models that
improve multithreaded programming performance.
A thread is a single sequential flow of control within a program. It is the active
execution of a designated routine, including any nested routine invocations. Within a
single thread, there is a single point of execution. Most traditional programs consist of a
single thread.
Threads are lightweight processes that share a single address space. Each thread shares
all the resources of the originating process, including signal handlers and descriptors.
Each thread has its own thread identifier, scheduling policy and priority, errno value,
thread-specific data bindings, and the required system resources to support a flow of
control.
6.1 Advantages of Using Threads
With a threads package, a programmer can create multiple threads within a process.
Threads execute concurrently and, within a multithreaded process, there are at any time
multiple points of execution. Threads execute within a single address space.
Multithreaded programming offers the following advantages:
Performance
Threads improve the performance (throughput, computational speed, responsiveness,
or some combination of these) of a program. Multiple threads are useful in a
multiprocessor system where threads run concurrently on separate processors. In
addition, multiple threads also improve program performance on single processor
systems by permitting the overlap of input and output or other slow operations with
computational operations.
124245 Tandem Computers Incorporated 61