|
|
UNIX System V Release 4.2 MP (SVR4.2 MP) and UnixWare 2.0 provide vastly expanded capabilities for concurrent programming via the Threads Library. These capabilities include:
General characteristics of threads programming:
Each thread of the process has access to all of the resources of the process including:
Any thread can access any memory location in the process. By using threads for concurrency, the programmer sacrifices the address space protection that the operating system maintains (with support of hardware features) between processes. A wild pointer in one thread can easily corrupt memory used by another thread.
On the other hand, thread-to-thread data sharing is easy and efficient. By default, all data is available to all threads. Thread-to-thread communication avoids the system call overhead and typical data copying of process-to-process communications.
The features that are unique to each thread include:
Actually, some signal handling features are maintained per thread and some are maintained at the process level. The relationship between the two (and how to use them) will be discussed later (see ``Threads and signals'').
The facilities of the Threads Library are well-suited for medium- to coarse-grained concurrency. It may be inappropriate to use the facilities of the Threads Library if:
``Overview of threads'' illustrates the relation of threads to LWPs to processes to processors. The terms ``multiplexed threads'' and ``bound threads'' are discussed elsewhere in this section.
Overview of threads