Add Book to My BookshelfPurchase This Book Online

Chapter 6 - Practical Considerations

Pthreads Programming
Bradford Nichols, Dick Buttlar and Jacqueline Proulx Farrell
 Copyright © 1996 O'Reilly & Associates, Inc.

Chapter 6: Practical Considerations
Overview
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 is something else. (We encourage you to write yours without bugs.) A multithreaded program can encounter errors, such as race conditions and deadlocks, that aren't found in a traditional program, and these types of errors are not easy to debug. Moreover, the command set of conventional debuggers allows you to direct only process execution; some may provide a similar command set to allow you to control the execution of threads. Armed with a suitable tool, how do we proceed to uncover and eradicate the bugs in our threads? 
Performance
We added threads to our program to obtain performance we couldn't achieve in a single-threaded version. How do we measure this performance? How can we tune it? 

Previous SectionNext Section
Books24x7.com, Inc © 2000 –  Feedback