O'Reilly logo

PThreads Programming by Bradford Nichols, Dick Buttlar, Jacqueline Farrell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Practical Considerations

In this chapter:

Writing a multithreaded program is a lot like being a bebop jazz musician in the late Forties. It’s great to know what notes to play and the order in which to play them, but if the object is to play “Cherokee” as fast as possible, technique doesn’t matter all that much. You need to fit as many notes in as short a space of time as possible and be done it with before the audience can catch its breath. It’s performance, performance, performance!

So it is with you, the writer of threaded applications. Portable library calls that provide task concurrency within a process are fine, but only if they deliver on the promised performance. So in this chapter, we move from the abstract to the practical, from the world of standards and reference pages to the world in which things often go wrong or don’t go as well as we’d like. With this in mind, our discussions will focus on:

Pthreads implementations

Pthreads implementations differ to the degree to which they’re based in user space or kernel space. The way in which a thread library is designed on a given platform determines how your threads are scheduled, whether they can actually run in parallel, and, ultimately, how well they perform. Knowing a little bit about how your platform supports Pthreads can help you design your program to take advantage of the implementation’s strong points

Debugging

Debugging a multithreaded program ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required