Back TU TTU Subject Area: Programming Languages and Paradigms in CIDEC Library.

PROGRAMMING WITH THREADS

Steve KLEIMAN, SunSoft, Inc.
Devang SHAH
Bart SMAALDERS

Publisher : Prentice Hall - Mountain View, Calif.

Bibliographic :

DESCRIPTION :

KEY BENEFIT: Written by the principal architect of Sunsoft's threads implementation, this practical guide to developing multithreaded programs on UNIX, concentrates on when and how to apply threads, what problems to expect, and how to deal with them.

KEY TOPICS: Covers advanced interfaces appropriate to performance-critical situations. Explores the use of threads and the construction of correct MT programs and libraries. Includes a variety of multithreading examples.

CONTENTS :

(NOTE: Each chapter concludes with a Summary).

PREFACE.

1. Introduction to Threads.
What Are Threads? The Benefits of Threads. Throughput Multiple Processors. User Interface Responsiveness. Server Responsiveness. Server Deadlock Avoidance. Program Structure. Communication. A Warning. Controlling Concurrency. Concurrent Programming.

2. Getting Started.
A Simple Example Using Threads. Threads Interfaces. Creating Threads. Using the Thread Start Routine Argument. Destroying Threads. Waiting for Threads to Exit. Getting the Current Thread-id. Comparing Thread-ids. Thread Attributes. Detached Threads.

3. Synchronization.
The Synchronization Problem. Synchronization Variables. Mutual Exclusion. Initializing and Destroying Mutexes. Locking and Unlocking Mutexes. Data Races. The POSIX Memory Model. Condition Variables. Initializing and Destroying Condition Variables. Waiting for and Signalling Conditions. Using Condition Variables. Using pthread_cond_broadcast(). Dynamic Package Initialization.

4. Using Libraries in Multithreaded Programs.
System Calls. errno. Thread-Safe Functions. Serializability. Restrictions on Concurrency. POSIX Thread-Safe Functions. Memory Allocation. stdio. C++ iostream Library. Explicitly Locked Functions. Thread-Unsafe Functions. Other Thread-Safety Variations. Package-Unsafe Functions. Object-Unsafe Functions.

5. Threads and Process Resources.
Process Resources. Unshared Resources. Positioned I/O. Arguments and Environment Variables. Timers and Waiting. Signals. Process Creation and Destruction. Using fork(). Waiting for Processes to Exit.

6. Synchronization Strategies.
Single Global Lock. Thread-Safe Functions. Structured Code Locking. Monitors. Internal Functions. Invariants. Releasing the Monitor Lock. Multiple Conditions. Structured Data Locking. Object Deletion. Locking and Modularity. Nested Monitors. Long Operations. Reentrant Monitors. Monitors Revisited. Deadlock. Lock Ordering. Resource Deadlocks. C++. Scoped Locking. Locking Guidelines.

7. Using Threads.
Creating Threads. Improving I/O Throughput. Using Multiple Processors. Improving User Interface Responsiveness. Improving Server Responsiveness. Program Structure. Server Deadlock Avoidance. Failure Attributes. Threads vs. Event Loops. Processes vs. Threads. Thread Paradigms. Deferring Work. Anticipating Work. Pipelines, Pumps, and Serializers. Sleepers and One-Shots. Deadlock Avoiders. Task Rejuvenation. Threading Data Structures. Linked Lists. Queues. Hash Tables. An Example.

8. Thread-Specific Data.
Thread-Specific Data. Allocating TSD keys. Accessing TSD Values. Using TSD. Deleting TSD keys. Considerations in Using TSD. Redefining Interfaces for Threads.

9. Signals.
Signal Mask. Signal Generation. Sending Signals to Threads. raise(). Signal Delivery. Signal Handlers. Async-Safe Functions. Nonlocal goto. Waiting for Signals. sigsuspend(). Pending Signals. Per-Thread Signal Handlers.

10. Advanced Synchronization.
Interprocess Synchronization. Synchronization Variables in Files. Interprocess Synchronization and Process Death. Semaphores. Named and Unnamed Semaphores. Creating and Opening Named Semaphores. Unlinking Named Semaphores. Initializing and Destroying Unnamed Semaphores. Waiting For and Posting Semaphores. Getting a Semaphore's Value. Using Semaphores. Semaphores and Signal Handlers. Semaphores and the Memory Model.

11. Thread Cancellation.
Destroying Other Threads. Cancelling Threads. Cancellation Points. Cancellation Cleanup Handlers. Cleanup Handlers and Condition Variables. Detaching Threads During Cancellation. Testing for Cancellation. Asynchronous Cancellation. Disabling Cancellation. Using Cancellation.

12. Threads Scheduling.
Thread Scheduling Models. Using Contention Scope. Thread Scheduling Attributes. Inheriting Scheduling Attributes. Thread Scheduling Policies. Priorities. Yielding. Scheduling Policies. Scheduling Allocation Domain. Priority Inversion. Priority Ceiling Protocol. Priority Inheritance. Scheduling Strategies. Thread Scheduling in Solaris 2. Concurrency and Process Contention Scope Threads. System Contention Scope Threads. Contention Scope and Process-Shared Synchronization Variables.

13. Threads and Processes: Advanced Topics.
Managing Thread Stacks. Default Stack Management. Thread Stack Size Limits. Managing Your Own Thread Stacks. Strategies for Using fork(). Fork Handlers.

14. Advanced Synchronization Strategies.
Critical Section Concurrency. Lessons from Queuing Theory. Read/Write Locks. Read/Write Lock Conditions. Breaking Up Locks. Explicitly Locked Functions. Recursive Locks. Object-Unsafe Functions. Locking Guidelines II.

15. Multiprocessor Issues.
Shared Memory Multiprocessors. Caches and Cache Consistency Protocols. Synchronization Instructions. Synchronization on Multiprocessors. Spin Blocking. Wait-Free Synchronization. Convoys. Livelock.

16. Parallel Computation.
Using Threads to Parallelize Algorithms. Thread Paradigms. Master-Slave Paradigm. Master-Slave Example: Matrix Multiply. Barrier Synchronization. Master-Slave Example: Relaxation. Spin Barriers. Workpile Paradigm. Workpile Controllers. Workpile Example: Quicksort. Pipeline Paradigm. Pipeline Example: Graphics Rendering. Pipeline Example: Relaxation. Parallelizing Using Compiler Techniques. Performance. Imbalance. Synchronization Overhead. Lock Contention. Data Sharing and False Sharing Overhead. Performance and Problem Size. Guidelines for Writing Parallel Programs.

17. Multithreading Existing Code.
Libraries. Thread-Safety. Cancellation-Safety. Fork-Safety. Establishing Fork Handlers. Applications. Multithreading a Graphical User Interface.

18. Threads Development Environment.
Compiling Multithreaded Programs. Other POSIX Libraries. Header Files. Static Data Race Analysis. lock_lint. Debugging. debugger on Solaris 2. Performance Tuning. Critical Path Analysis. Critical Section Analysis. Profiling. Tracing.

A. Example Programs.

B. UNIX International Threads.
Overview. POSIX/UI Common Features. Additional Features of the UI Interface. Read/Write Locks. UI Resource Limits. Suspend and Continue. Daemon Threads. Forking Multithreaded Processes. Avoiding Data Races. Thread Scheduling. Concurrency Level. Thread Priorities. Scheduling Classes. Compiling and Linking UNIX International Programs. Header Files.

C. Manual Pages
threads(3T). cancellation(3T). condition(3T). mutex(3T). pthread_atfork(3T). pthread_attr_init(3T). pthread_condattr_init(3T). pthread_create(3T). pthread_detach(3T). pthread_equal(3T). pthread_exit(3T). pthread_join(3T). pthread_kill(3T). pthread_mutex_setprioceiling(3T). pthread_mutexattr_init(3T). pthread_once(3T). pthread_self(3T). pthread_setschedparam(3T). pthread_sigmask(3T). rwlock(3T). semaphore(3T). thr_min_stack(3T). thr_setconcurrency(3T). thr_suspend(3T). thr_yield(3T). sched_get_priority_max(3R). sched_setparam(3R). sched_setscheduler(3R). sched_yield(3R). sem_close(3R). sem_destroy(3R). sem_getvalue(3R). sem_init(3R). sem_open(3R). sem_post(3R). sem_unlink(3R). sem_wait(3R). sigwaitinfo(3R). sigwait(2). ctime(3C). directory(3C). getgrnam(3C). getlogin(3C). getpwnam(3C). rand(3C). string(3C). sysconf(3C). ttyname(3C).

D. Annotated Bibliography.

Includes bibliographical references (p. 515-520) and index.

BOOK CATEGORY : For programmers interested in developing multithreaded programs on UNIX.


Back Top Changed 24/01/1997. Comments: monika@cs.ioc.ee