| |
| |
Preface | |
| |
| |
| |
The Process Model | |
| |
| |
The [Single-Threaded] Process | |
| |
| |
The Context of a Process | |
| |
| |
The Process Model Operating System | |
| |
| |
Process Scheduling | |
| |
| |
Process Context Switches | |
| |
| |
Process Life Cycle, Modes, States, and Transitions | |
| |
| |
An Illustration of a Process | |
| |
| |
The Limitations of Single-Threaded Programs | |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
The Thread Model | |
| |
| |
Analogy of Single-Threaded Execution | |
| |
| |
Analogy of Multithreaded Execution | |
| |
| |
The Benefits of Threads | |
| |
| |
Thread Context, Modes, States, and Transitions | |
| |
| |
User Threads and Kernel Threads | |
| |
| |
Bound and Unbound Threads | |
| |
| |
The Thread Model Operating System | |
| |
| |
Many-to-One (Mx1) | |
| |
| |
One-to-One (1x1) | |
| |
| |
Many-to-Many (MxN) | |
| |
| |
An Illustration of a Multithreaded Program | |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Introduction to POSIX | |
| |
| |
The POSIX Standard | |
| |
| |
POSIX Components | |
| |
| |
POSIX Options | |
| |
| |
Compile-Time Checking | |
| |
| |
Run-Time Checking | |
| |
| |
Namespace Reservation | |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Basic Thread Management | |
| |
| |
Relating Process and Thread Model Functions | |
| |
| |
Creating a Thread | |
| |
| |
Waiting for a Thread | |
| |
| |
Detaching a Thread | |
| |
| |
Terminating a Thread | |
| |
| |
Finding and Comparing Thread Ids | |
| |
| |
Performing One-Time Initialization | |
| |
| |
Establishing Fork Handlers | |
| |
| |
Creating Specialized Thread Attributes | |
| |
| |
Handling Thread Management Errors | |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Thread Synchronization | |
| |
| |
Thread Synchronization | |
| |
| |
Mutexes | |
| |
| |
Mutex Attributes | |
| |
| |
Initializing and Destroying Mutexes | |
| |
| |
Locking and Unlocking Mutexes | |
| |
| |
Example: Mutexes and Spinlocks | |
| |
| |
Condition Variables | |
| |
| |
Condition Variable Attributes | |
| |
| |
Initializing and Destroying Condition Variables | |
| |
| |
Waiting on a Condition | |
| |
| |
Signaling a Condition | |
| |
| |
Example: Condition Variables and Barriers | |
| |
| |
Semaphores | |
| |
| |
Initializing and Destroying Unnamed Semaphores | |
| |
| |
Locking and Unlocking Semaphores | |
| |
| |
Handling Synchronization Errors | |
| |
| |
Memory Models and Synchronization | |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Thread Scheduling | |
| |
| |
Thread Scheduling Contention Scopes | |
| |
| |
Thread Scheduling Policies | |
| |
| |
Sched_fifo. Sched_rr. Sched_other | |
| |
| |
A Thread's Scheduling Policy and Priority | |
| |
| |
Thread Scheduling Priority Values | |
| |
| |
Thread Scheduling Allocation Domains | |
| |
| |
Thread Creation Scheduling Attributes | |
| |
| |
Dynamic Thread Scheduling | |
| |
| |
Yielding the Processor | |
| |
| |
Priority Inversion and Mutexes | |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Threads and Signals | |
| |
| |
Signals in the Thread Model | |
| |
| |
Synchronous and Asynchronous Signals | |
| |
| |
Examining Changing a Thread's Signal Mask | |
| |
| |
Sending Signals to Threads | |
| |
| |
Waiting for a Signal | |
| |
| |
Async-Signal Safe Thread Functions | |
| |
| |
A New Signal Delivery Method: Sigev_thread | |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Thread Cancellation | |
| |
| |
Thread Cancellation | |
| |
| |
Thread Cancelability States | |
| |
| |
Cancellation Points | |
| |
| |
Setting Thread Cancelability States | |
| |
| |
Creating a Cancellation Point | |
| |
| |
Installing Cancellation Cleanup Handlers | |
| |
| |
Canceling a Thread | |
| |
| |
Async-Cancel Safety | |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Thread-Specific Data | |
| |
| |
Thread-Specific Data | |
| |
| |
Creating Thread-Specific Data Keys | |
| |
| |
Deleting Thread-Specific Data Keys | |
| |
| |
Accessing Thread-Specific Data Elements | |
| |
| |
The Special Case, errno | |
| |
| |
Example: Per-Thread Signal Handlers | |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Thread Extensions | |
| |
| |
HP and X Open Thread Extensions | |
| |
| |
Thread Stack Attributes | |
| |
| |
Suspending and Resuming Threads | |
| |
| |
Mutex Extensions | |
| |
| |
Condition Variable Expiration Time | |
| |
| |
Read-Write Locks | |
| |
| |
Read-Write Lock Attributes | |
| |
| |
Initializing and Destroying Read-Write Locks | |
| |
| |
Locking and Unlocking Read-Write Locks | |
| |
| |
The Timeshare Scheduling Policy | |
| |
| |
Thread to Processor Binding | |
| |
| |
Thread Concurrency and MxN Threads | |
| |
| |
Scheduling Unbound Kernel Entities | |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Thread F X | |
| |
| |
fork(), exec(), exit(), and wait() | |
| |
| |
File and Message-Passing Operations | |
| |
| |
Signals | |
| |
| |
Locale State | |
| |
| |
Timers and Sleepers | |
| |
| |
NonLocal Jumps | |
| |
| |
Scheduling | |
| |
| |
Other Functions | |
| |
| |
Summary | |
| |
| |
Exercises | |
| |
| |
| |
Writing Thread-Safe Code | |