Programming with POSIX(R) Threads
David R. Butenhof


Compras Nikon
Bluetooth
1 Better than some other reviewers thought
I started reading this book in 2000 when I already had programming experiences with threads (Linux/SUN/SGI/Windows thread packages). This book is very helpful to improve my understanding of threads overall (not only Posix threads which is the focal point of the book).

The most difficult part of thread programming is synchronization. This is where most problems arise in reality and most of this book's focus is on. The author clearly starts with various versions of implementation using different techniques (wrong or right) to help readers gain more knowledge. This (unlike one other reviewers claims to be confusing) is good writing style in my mind.

There may be some misunderstanding from other reviewers too. One claims mutex is associated with both data and code. But mutex should always be associated with data (to protect data's coherency and consistency) and I don't see the book tries to associated that with code (its usage is certainly always in the form of code, which is the only way to use it). Another claims there is no downloadable code, which is wrong. The appendix of the book clearly states the URL of the downloadable source sample code (also include errata of the book). (...)
The book is not without problems. The main issue I think is lack of introduction to popular Posix thread implementation. Almost no Posix thread implementation strictly conforms to the standard (this is also why some code in the book may not run readily on some implementation - make no mistake, most do). It will be helpful to explain different issues under different implementations and how to deal with it. The other thing is I found one minor problem with one sample code - it uses pthread_t type to do integer comparison which is discouraged by the author himself (this strikes one peculiarity of Posix standard: it uses opaque type for pthread_t, instead of scalar type which is very convenient to do such comparison in reality. Even the author as member of the standard committee is lured to do that).

Overall, I think the book is worth at least 4 star and the money.
2 A frustrating book
Richard Kirk's review below is the most accurate. There are many annoying things about this book. In addition, I find the code suspicious. For example the examples he gives of mutexes is to associate them with data items, even though the vast majority of the time they're associated with executable code. The discussion of critical sections is basically non-existent with very little explanation of the equivalent functionality in Pthreads. His explanation of semaphores is very difficult to follow and far more complex than it need be. I found better and simpler tutorials on the Web.

Butenhof is at his best when explaining the deep stuff and the subtle aspects of parallel programming. If this is what you need, the book is great. But if you want someone to show you how to use Pthreads and enable you to get up to speed quickly, then you will find this book rather frustrating.

The absence of downloadable code is an additional frustration. I'd go with the books by Bil Lewis, which are more straightforward and he offers tons of downloadable examples.


3 Comprehensive and well-written
Butenhof covers all the details of programming the pthreads library. The book begins with a lucid and carefully presented discussion about the general concepts behind threading, such as locking, synchronization, race conditions, and data sharing. Threads can be a bit intimidating, but Butenhof's presentation makes threaded programming, and thinking about asynchronous design in general, much more manageable. His coverage of the library itself is very accurate and clear. The book helpfully contains a complete reference of the pthreads library. Another worthwhile feature is the discussion and implementation of several common design patterns for multithreaded programming. I have found myself modifying and reusing these patterns again and again. If you find yourself needing to program with the pthreads library, Butenhof will not lead you astray. Highly recommended.
4 Reading Pleasure
I like to read books written that way.

To whom English is a foreign language an author's writing style
and choice of expression is sometimes the most important detail.

This book about POSIX-threads is for me. I respect THE OTHER
author's achievment. Also, I do not know how much of the
contents is outdated in either publication...

So, this is not about the quality of each snippet of Code, but
about the _usefulness of a book_ to teach POSIX-threads
comfortably to a complete beginner on the subject.

Take a copy, read some paragraphs from different chapters and
get an impression, before you buy any book on POSIX threads.

This one would be my first choice. :-)


5 Not bad
I found this book very useful when learning about POSIX threads though the whole impression is a bit mixed.

The book gives everything you need to start writing POSIX-style multithreaded applications. Very complicated (in my opinion) issues of multithreading are explained very clearly. Every new concept is immediately illustrated with a sample code.

The appendix contains a detailed description of all mentioned pthread functions, so you can use it as a reference too.

At the same time I am not sure if book is completely up-to-date. E.g., in chapter 7 the author explains in details what is a read/write lock and presents a code with a mutex and 2 condition variables to use as an r/w lock. In the appendix he says that r/w lock can be incorporated into POSIX as a separate entity in future. I work with Solaris 8 and I found that r/w locks are already in my POSIX library.

The style of book is quite special, you may love it, or you may hate it. Sometimes the very basic concepts are explained in such a way and with so repetitions that it becomes even a bit annoying. Those bailing programmers are also a bit annoying. Quotes from Lewis Carroll seem a bit off topic too. Of course it's just my opinion.

In general I think the book worth its money and recommend it to everyone interested in the subject.

Prerequisites are simple: knowledge of C and general POSIX. E.g., I recommend a book by Mr. Gallmeister on real-time (non-multithreading) POSIX.


6 Reference book for POSIX threads
This book is a fine reference for POSIX threads. It will teach you the why's and how's of thread programming with illustrative examples. It will also tell you about the choices that were made for the threads standard. Finally, it acts as a reference book for the POSIX threads standard.

The book delivers what you would expect from a book on POSIX threads, nothing more, nothing less.


7 Basically OK but not great
It's easy for me now - I compare all programming books I read to the definitive gem of technical writing - Stevens UNPv1. The pthreads book is fine in a sense that it does explain threads yet it definitely lacks certain qualities UNPv1 posesses. Anyway, since 99.9% of any book's reviews on Amazon may be condensed into a single phrase 'I think this book is great', I'll try to provide more information by focusing on bad stuff.

- code examples are rather simplistic, with no attempt to show some real-life application

- Unlike Stevens, the author doesn't try to cover multiple UNIX implementations' specifics in a systematic manner (Stevens covered at least 6 flavors of UNIX!)

- Unlike Stevens, the author doesn't bother to show the results of running programs on multiple UNIX systems

- Typical threads programming mistakes are explained without showing any code. This is not the way I prefer it - I'd rather see a project spec, then an obvious (and wrong!) implementation with explanation of a mistake, then iterations of improvements up to a proper implementation

- The material definitely targets a VERY inexperienced person. The first half of the book is way too slow, especially compared to the 2nd half

- I found excerpts from Alice distracting and the pictures crude :-) . This is not what I expect to find in a technical book.

All in all, I don't like this book much - yet make no mistake - it will teach you how to program with pthreads. You won't enjoy the same sharp and intelligent style you'd get in UNPv1 (or on the opposite, you won't be so bored with technical details, if you don't like Stevens), but you will get the required information from it. After all, the author was part of the POSIX pthreads standardization group, so he knows what he is talking about.

PS. The UNPv1 book mentioned in this review is about NETWORK PROGRAMMING, not threads and it is in no way suggested as a replacement reading for the book reviewed.


8 Annoying, but probably no worse than the rest...
This book has got what you want to know about pthreads. If that was all it had, and it had that in the right order, then it would be perfect. Instead, this is a very frustrating book to read.

Take 'mutexes' as an example. A useful explanation for a beginner might be as follows... (1) Where the word 'mutex' comes from (2) What a memory conflict is (3) How a mutex can avoid it (4) How it works (simplified) (5) Some good examples in programs

On page 6 we first meet a mutex in a bit about putchar - we turn 'putchar into a 'critical section' (unexplained) because 'putchar might lock a "putchar mutex" '.

Don't bother trying to understand it. Next paragraph, we find 'the correct solution is to associate the mutex with the stream', so it was a bad idea in the first place. Oh.

Two chapters later, on page 47, you get to know what a 'mutex' is. It's mutual exclusion using a special form of Edsger Dijkstra's semaphore, you dummy. Well, if you've read Edsger Dijkstra's 1968 paper, then you aren't likely to be reading this book, says I.

Confused? Keep going. Finally on page 90, there is a neat tabular description of one thread reading a variable before the other one has written it, and how you can stop this with a mutex. Clear and simple, this should have been on page 6. The following section (marked "You may want to skip this explanation...") then describes the sorts of problem you get with real hardware - surely a 'must read' if you are going to do this sort of stuff.

There is a noble tradition of giving a bad coding example in one chapter, so you can show how cleverly you can fix it in the next. Look at any Stroustrop book. I think this is a bad idea - every example of code ought to be as good as you can make it: someone might just lift the section from your code as it stands. Anyway, I wasted a lot of time pouring over a 3-page example program because I was convinced it did not work, only to find that the author knew it had a bug in it, but was keeping up the suspense to the next section.

While I'm on pet hates, if I wanted Lewis Carroll, I would have bought Lewis Carroll: we could loose the quotes. And the cartoons of "Three Men in a Boat". And the explanations of what the zero in the Unix clock means every time it is used.

Ooohhh, this book could be so much shorter, and sooo much better. Still, I have got my program going, and that's the main thing.


9 First Rate. Clear and authoritative
This book provides the clearest, most concise, and most authoritative treatment of POSIX threads that I have seen. The author is a recognized expert and explains how and why Pthreads operates as it does. I approached this book with some fundamental misunderstandings and concerns with respect to Pthrreads, and, after reading a few chapters, everything became clear, obvious, and natural. Furthermore, the author avoids the mistakes, important omissions, and misleading statements that are common in many other multithreading books and articles. The example programs provide additional insight, and the solutions can be used to solve many practical problems.

Chapter 8 ("How to Avoid Debugging") is a classic and provides sound advice; I often recommend this chapter to Windows programmers as the advice applies to all multithreaded systems, not just Pthreads. Numerous deadlocks, race conditions, and other all too common bugs can be avoided after a careful reading of this chapter.

The author is active in the comp.programming.threads discussion group, and his thorough and thoughtful responses, similar to the explanations in the book, have helped to clear up numerous misunderstandings.


10 Really portable!
This book can make your job easier if you are coding in multi threaded programming environment. It is really helpful for the beginners like myself in this subject area. Almost everyone in my team has a copy of this book.

The things that I like the most about this book are the clear cut explanation of POSIX functions coupled with 'working' compile-able examples. Throughout the book the author tells you how to avoid common mistakes and this is what makes it a really practical everyday kinda book.

I keep this book on my desk at all times. Perhaps, the best book on POSIX so far.


11 Best threads book I've read
Well organized, very useful examples. The author annotates all the source code listings. Source code available on the Web.
12 Detailed and easy to understand
This book is great for beginners in Posix. It is detailed and clear. It gives careful explanation of the major Posix functions and complement them with full source codes which compiles perfectly, making everything easier to understand.
13 The best (POSIX) Threads book I could find.
This book is very focused on multi-threaded programming with an emphasis on POSIX threads. The example code is always carefully explained, and is always clear and to the point.

A great book for understanding multithreading concepts, for 'how to' examples, and for advice for avoiding the many pitfalls.

If you need to write portable, maintainable threads code that works, this book is a good place to start. I wish the person who wrote the code I now have to debug had read this book and followed Butenhof's teachings!


14 one of the two best books
there is on the topic! Covers almost every facette of threads, gives good examples and background information. An absolute must if U want to program threads
15 It's good and clear
This is the best pthread book I found so far. The Author used good and simple examples to make pthread concept easy to understand.
16 Excellent book on Pthreads
This book was the best of 4 books that I've read on the topic. The coding examples were all very good and the text covered a great number of topics in the necessary detail (very clear and concise). I just wish I'd read this first -- I wouldn't have needed to read the other three books.
17 Basically Good Stuff
Well written, easy to understand. I enjoy reading it thorougly. Only reason it isn't a 5 star is that the font is so freaking large. Come on! My enlish teacher wouldn't let me get away with this kind of stuff... Neither will I.

But, for learning about POSIX threads, this book is nice. Not too technical, not to 'POSIX for Dummies' either...



Sunday, 07-Sep-2008 10:40:51 CDT
Quote of the Day:


From the cradle to the coffin underwear comes first.

-- Bertolt Brecht

Truth never comes into the world but like a bastard, to the ignominy
of him that brought her birth.
-- Milton