PThreads Programming
A POSIX Standard for Better Multiprocessing
By Bradford Nichols, Dick Buttlar, Jacqueline Proulx Farrell
September 1996
Pages: 286
ISBN 10: 1-56592-115-1 |
ISBN 13: 9781565921153




(Average of 1 Customer Reviews)


Description
POSIX threads, or pthreads, allow multiple tasks to run concurrently within the same program. This book discusses when to use threads and how to make them efficient. It features realistic examples, a look behind the scenes at the implementation and performance issues, and special topics such as DCE and real-time extensions.
Full Description
Computers are just as busy as the rest of us nowadays. They have lots of tasks to do at once, and need some cleverness to get them all done at the same time.
That's why threads are seen more and more often as a new model for programming. Threads have been available for some time. The Mach operating system, the Distributed Computer Environment (DCE), and Windows NT all feature threads.
One advantage of most UNIX implementations, as well as DCE, is that they conform to a recently ratified POSIX standard (originally 1003.4a, now 1003.1c), which allows your programs to be portable between them. POSIX threads are commonly known as pthreads, after the word that starts all the names of the function calls. The standard is supported by Solaris, OSF/1, AIX, and several other UNIX-based operating systems.
The idea behind threads programming is to have multiple tasks running concurrently within the same program. They can share a single CPU as processes do, or take advantage of multiple CPUs when available. In either case, they provide a clean way to divide the tasks of a program while sharing data.
A window interface can read input on dozens of different buttons, each responsible for a separate task. A network server has to accept simultaneous calls from many clients, providing each with reasonable response time. A multiprocessor runs a number-crunching program on several CPUs at once, combining the results when all are done. All these kinds of applications can benefit from threads.
In this book you will learn not only what the pthread calls are, but when it is a good idea to use threads and how to make them efficient (which is the whole reason for using threads in the first place). The authors delves into performance issues, comparing threads to processes, contrasting kernel threads to user threads, and showing how to measure speed. He also describes in a simple, clear manner what all the advanced features are for, and how threads interact with the rest of the UNIX system.
Topics include:
- Basic design techniques
- Mutexes, conditions, and specialized synchronization techniques
- Scheduling, priorities, and other real-time issues
- Cancellation
- UNIX libraries and re-entrant routines
- Signals
- Debugging tips
- Measuring performance
- Special considerations for the Distributed Computing Environment (DCE)
Featured customer reviews

Pthreads Programming Review,
October 25 2000
Submitted by Sanjeev Patel
[
Respond |
View]
The book was OK when I first read it. However, I think that it lacks necessary detail about thread synchronization. The mutex/condition variable example using inc_counter and watch_count wouldn't work. Frankly, I've found that there are a lot of problems one will run into if they try to develop an app after having read this book. No attempt is made to discuss what happens when a thread waiting on a condition variable doesn't get to run even though it has been signalled (using pthread_cond_signal). The gloss over of pipelining was particularly annoying to me since I really wanted to implement a working pipeline using pthreads, but haven't been able to due to the problem mentioned above. I could be missing something, but the point of the book is to ensure (at least on some level) that I'm not...
Pthreads Programming Review,
March 25 1999
Submitted by len b (seven-three-six-six-2-dot-2-six-f
[
Respond |
View]
It's pretty decent and covers quite a bit of
ground. A nice book to start with. Otoh, it's not
very deep, and you'll definitely need more
although more on concurrent programming than
pthreads per se, I'd say. Another pretty good
book I have is "Programming with Threads", by Steve
Kleiman, and others.
Pthreads Programming Review,
March 01 1999
Submitted by Doug.Campbell@trw.com
[
Respond |
View]
I'd like to report an errata: On page 111 of the February 1998 edition (which I purchased last week at Bookstar), the text states that _POSIX_THREAD_ATTR_PRIORITY_SCHEDULING determines whether a system implements priority scheduling. Page 150 restates this, referring to
the compile-time constant _POSIX_THREAD_PRIORITY_SCHEDULING. An examination of my IRIX 6.4 /usr/include/unistd.h file
indicates that the latter is used. A grep of the entire /usr/include subtree turned up no uses of _POSIX_THREAD_ATTR_PRIORITY_SCHEDULING.
Read all reviews
Pthreads Programming Review,
February 25 1999
Submitted by Chad Kanotz
[
Respond |
View]
I found the text and examples to be highly informative. More attention could have been paid to debugging, and none at all was paid to OO implementation, but this is a great beginning text for POSIX threads.