Have one to sell? Sell yours here
Thread Time: The MultiThreaded Programming Guide
 
See larger image
 
Tell the Publisher!
I'd like to read this book on Kindle

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.

Thread Time: The MultiThreaded Programming Guide [Paperback]

Scott J. Norton (Author), Mark D. DePasquale (Author), Mark DiPasquale (Author)
4.0 out of 5 stars  See all reviews (4 customer reviews)


Available from these sellers.



Book Description

Hewlett-Packard Professional Books November 1, 1996
Threads are a powerful tool that allow programmers to improve their performance and structure of applications and utilize all the power of today's high performance computer. This book provides programmer's with a multithreaded programming learning tool, teaching tool, and reference all in one. The accompanying CD-ROM includes all code examples in the book.


Editorial Reviews

From the Publisher

Understand multithreading, the next dimension in high-performance computing. Thread Time is the easiest programmer's guide to the important new multi-threading techniques that are increasingly important in Windows NT/95, UNIX, POSIX, and other application development. Each concept in the book is illustrated with a picture, making this an exceptionally easy-to-understand book. The book introduces the process model, the thread model, and basic thread management functions. Learn how to synchronize and schedule threads. In a Programming Guidelines chapter, learn the basic do's and don'ts of multithreaded programming. The book includes extensive examples, exercises and references, including manual pages, debugging advice, and a CD-ROM loaded with practical information. This book is an effective introduction to multithreading for both professional programmers and students.

From the Inside Flap

PREFACE

Although threads have been around for decades, the use of threads on UNIXâ systems only started to become popular in the early 1990s. During this time, multiprocessor systems, client/server applications, and graphical user interfaces (GUIs) were making their way into the UNIX mainstream. Into this new era for UNIX, threads brought many benefits, but the most important was (and still is) performance. A multithreaded program can achieve significant performance gains through concurrent and/or parallel thread execution.
Concurrent thread execution means that two or more threads are in progress at the same time. If one thread blocks for some reason, another thread from the same program can execute in its place. This feature is especially relevant for cli- ent/server, GUI-based, and general I/O-bound applications. Parallelism occurs when two or more threads execute simultaneously across multiple processors. Parallelism exploits the processing power of multiprocessor systems and is espe- cially useful for compute-bound applications. Yet, threads are not a panacea. For example, thread management carries with it a certain amount of overhead. Thus, in order for a program to achieve a net performance gain, the concurrency or parallelism benefit must outweigh the thread management overhead liability. Fortunately, many applications can use threads to achieve significant perfor- mance gains.
This book teaches the application of multithreaded programming with the instruction, examples, and reference material needed to exploit this important software technology. Thread Time is primarily designed to be a practical guide for programming with POSIX.1c threads (also known as Pthreads). The Pthreads interfaces are presented and explained in detail. Code examples are provided, both in this book and on CD-ROM, that show how the interfaces are used. Guidelines teach you when to use threads, how to use them, how to avoid problems, and how to solve problems when they arise.
Thread Time may be suitable as a textbook in an advanced undergraduate or first-year graduate computer science curriculum. Clear objectives are provided at the beginning of each chapter, and exercises that help reinforce your knowl- edge of the technology are provided at the end of each chapter. The code exam- ples in this book are written in the C programming language.

Chapter Organization and Descriptions.
Although this has not been done explicitly, this book can be divided into five parts: Foundational Information, Pthreads Interfaces and Their Use, Program- ming with Threads, Advanced Topics, and Reference Material. Depending on your needs, you may wish to skip to a particular part or chapter.

1. Foundational Information.
Chapter 1: The Process Model chapter provides a foundation for understand- ing the benefits of threads. Herein, we present an overview of two areas: (1) the single-threaded process and (2) the process management portion of the UNIX operating system. At the end of this chapter, we draw a few conclusions about the limitations of single-threaded programming. Definitions for the Process Model, a process, and a thread are found in this chapter.
Chapter 2: The Thread Model chapter builds a foundation for programming with threads. Presented are several attributes of programs suitable for threads, several benefits of threads, and a high-level overview of three Thread Model operating systems. A number of essential definitions and concepts are provided in this chapter.
Chapter 3: The Introduction to POSIX chapter provides a brief introduction to the structure of POSIX and teaches you how to verify which POSIX thread functionality is supported on your system.
2. Pthreads Interfaces and Their Use.
Chapter 4: This chapter presents the Basic Thread Management interfaces and explains how they are used. These interfaces allow you to create, terminate, and synchronize threads. Specialized attributes are also available for creating threads with unique characteristics.
Chapter 5: The programmer assumes more responsibility when programming with threads. Thread operations must occur in the correct order, access to shared objects must be coordinated, and all threads must work together to achieve the desired result. Several mechanisms are available to coordinate, or synchronize, threads within a program. The Thread Synchronization chapter explains how to use these mechanisms.
Chapter 6: To accommodate varying needs, the scheduling policy and priority of POSIX.1c threads can be programmatically controlled. This chapter presents the Thread Scheduling interfaces, explains how they are used, and describes how threads compete for processor time.
Chapter 7: When a single-threaded process receives a signal, the default action is to terminate the process unless a signal handler has been installed. If a signal handler is invoked, program execution is interrupted. In a multithreaded pro- gram, signal handling is more flexible. A signal can be handled by a single thread within the program, allowing other threads to continue execution. The Threads and Signals chapter presents the Pthreads signal interfaces and explains how they are used.
Chapter 8: When programming with threads, it is often necessary to terminate a thread within the application. Signals appear to provide the most logical means to accomplish thread termination. However, signals have two major draw- backs: (1) if a signal causes a thread to terminate, the entire process terminates and (2) if POSIX allowed a signal to cause thread termination (and not process termination), mutexes and other resources acquired by terminated threads would never be released. The latter case could lead to deadlock. This chapter pre- sents the Thread Cancellation interfaces, explains the concept of thread can- cellation, and explains how resources are released when a thread is canceled.
Chapter 9: When a multithreaded program is written, a determination must be made as to how global data will be shared among the threads in the process. There are two choices: (1) a global data variable can be process shared and pro- tected with synchronization primitives; or (2) a global data variable can be spe- cific to each thread. In the second case, Thread-Specific Data is employed and synchronization is not required. This chapter presents the thread-specific data interfaces and explains how they are used.
Chapter 10: The HP-UX system includes several Thread Extensions, such as read-write locks, enhanced MxN Model scheduling control, processor affinity, and additional mutex types. Many of these features are thread extensions pro- vided by the X/Open Portability Guide. Some of these features are provided only by Hewlett-Packard and may not be portable. Nevertheless, all of these are pow- erful features that can enhance multithreaded programs.
Chapter 11: The Thread F/X (Effects) chapter discusses the behavior of com- mon library functions when they are used in multithreaded programs. For exam- ple, what happens when a thread calls fork? If a thread locks a file, will other threads in the same program still have access? Are there performance or porta- bility considerations when common library functions are used in multithreaded programs? Questions such as these are answered in this chapter.
3. Programming with Threads.
Chapter 12: The Writing Thread-Safe Code chapter defines thread-safing terminology and then describes several important facets of writing thread-safe code. At the end of this chapter, we provide a preflight checklist for designing thread-safe libraries.
Chapter 13: The Programming Guidelines chapter provides specific guide- lines for programming with threads based upon the information presented in the previous chapters. These guidelines include best practices, performance and portability tips, and constructs to avoid.
Chapter 14: You have written your multithreaded application. It compiles. However, when running the application, you notice some unexpected behavior. Perhaps a value from a calculation is incorrect, I/O is interleaved, or perfor- mance is poor. Alternatively, you may notice that certain tasks are incomplete or maybe the entire program hangs. The Debugging Threaded Applications chapter presents symptoms, probable causes, and possible solutions for you to consider during your systematic debugging process.
4. Advanced Topics.
Chapter 15: The Parallel Programming Models and Issues chapter dis- cusses several software models suitable for multithreaded programs. Some mod- els are suitable for I/O-bound applications; others are suitable for compute- bound applications. The former exploit the concurrency benefit whereas the lat- ter uses parallelism to exploit the power of multiprocessor systems. A discussion of parallel programming issues follows. Several important issues relating to thread creation, thread synchronization, and multiprocessor cache thrashing are identified. Specific techniques, guidelines, and solutions are also presented.
5. Reference Material.
Appendix A: The Pthread Manual Pages in this appendix come directly from Hewlett-Packard's HP-UX Release 10.30. They appear in this book exactly as they appear on-line. Many thanks to Hewlett-Packard for allowing us to publish these manual pages.
Appendix B: Glossary.
Appendix C: Bibliography.

Conventions Used in this Book.
1. Chapters.
To assist in rapid learning and to provide ease of use, information in this book is presented in modular form. Chapters are divided into sections; each section cov- ers a particular topic. A section is composed of a title, descriptive picture, synoptic caption, full text explanation, and guidelines or code examples as appropriate. Here is a simplified example of a section:
Protecting Shared Objects.
Fig. 3-7 Use a mutex to serialize access to a shared object. If a piece of shared data will never be modified, a mutex is not needed.
A mutex is a mutual exclusion object that is used to serialize access to shared objects. Once a thread locks a mutex, other threads wishing to gain access to the shared object block until the mutex is unlocked.
Not all shared objects require protection. For example, if a piece of shared data will never be modified, there is no need to protect that data with a mutex.
Guidelines.
* decide which shared objects require serial access
* use one mutex for each shared object requiring
serial access
Example

pthread_mutex_t m;

pthread_mutex_lock(&m);

pthread_mutex_unlock(&m);


The title of each section is given in the “Topics Covered” portion of each chap- ter introduction. Sections are presented in the same order listed. The last section in each chapter is followed by a chapter summary and exercises.
2. Use of Fonts.
Bold is used to indicate great importance.
Italics is used for definition of terms, emphasis, function arguments, or ref- erences to chapters (e.g., see Chapter 5, Thread Synchronization).
Courier is used for function names e.g., pthread_create() and for code examples.
Bold courier is used for macros and definitions referenced in the text.
CD-ROM and Code Examples
This book contains numerous code examples. To provide focus, many examples omit included files, declarations, and error checking. The CD-ROM packaged with Thread Time contains full, working versions of all code examples presented herein. In addition, templates are provided for several parallel programming models.
The CD-ROM has been formatted in the ISO 9660 and Rock Ridge file system formats. These formats are suitable for use on most operating system platforms. To access the code examples, mount the CD-ROM as a file system. The examples should then be copied to your local file system so that they may be compiled and/ or manipulated.

Acknowledgments.
We're indebted to the following individuals who performed a full review of the technical material contained herein: Greg Astfalk, Bruce Blinn, Wayne A. Booth, Tom Doeppner, Edith Epstein, Duncan Missimer, Ann Schneider, Richard Mar- lon Stein, Tom Watson, and Joel Williamson. Their valuable feedback has gone a long way to improve the quality of this book. Special thanks to Ann Schneider for reviewing and editing the manuscript many times and answering countless edit- ing questions at all hours of the night. We would also like to thank Tony Coon, Marti Jones, Doug McKenzie, and Anil Rao for their constructive technical and editorial comments.
We would especially like to thank our families, Ann, Amy, and Ann, for their sup- port, patience, and encouragement throughout the writing of this book.

Product Details

  • Paperback: 560 pages
  • Publisher: Prentice Hall PTR (November 1, 1996)
  • Language: English
  • ISBN-10: 0131900676
  • ISBN-13: 978-0131900677
  • Product Dimensions: 9.1 x 6.9 x 0.9 inches
  • Shipping Weight: 1.8 pounds
  • Average Customer Review: 4.0 out of 5 stars  See all reviews (4 customer reviews)
  • Amazon Best Sellers Rank: #1,902,625 in Books (See Top 100 in Books)

More About the Author

Discover books, learn about writers, read author blogs, and more.

 

Customer Reviews

4 Reviews
5 star:
 (1)
4 star:
 (2)
3 star:
 (1)
2 star:    (0)
1 star:    (0)
 
 
 
 
 
Average Customer Review
4.0 out of 5 stars (4 customer reviews)
 
 
 
 
Share your thoughts with other customers:
Most Helpful Customer Reviews

5 of 5 people found the following review helpful:
4.0 out of 5 stars You need another book as well..., September 29, 2002
By 
Jo Totland (Oslo, Oslo Norway) - See all my reviews
This review is from: Thread Time: The MultiThreaded Programming Guide (Paperback)
Having recently re-read this book, I find it's explanations of various concepts relatively clear, if a little verbose. The book is 50% of the time quite good at explaining something, and 50% of the time exceedingly dull and tedious, obviously large parts of boilerplate text must have been cutted and pasted into various parts of the text.

What the book does not give you, is an introduction to concurrent programming. This is a pity, because most programmers aren't especially well trained in tackling concurrent programming. The mindset involved is different, and formal proofs suddenly becomes more important than debugging.

To make matters worse, the examples in the book is completely and utterly useless. In the first half of the book, they typically exercise one API function at the time, with 5 lines of comments per api call. In the latter half, sometime, you can see a few API calls in sequence, but none of the examples in the book will help you getting ideas for how to structure a complete multithreaded application.

On the bright side, to someone already knowledgeable about concurrent programming, the discussions in the book of the same issues related to pthreads make it possible to gain a thorough understanding of how to program pthreads safely.

Would I recommend the book? Yes, I am not aware of that many other pthreads books, but this book clearly has a lot of useful content. But it certainly has a split personality. Half the time, targetting the idiot who can't even figure out how to call an api function given the prototype and a description of it's semantics, and half the time giving actual useful information on issues regarding the use of pthreads and its interaction with processes, signals, and other parts of the unix environment.

Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


5 of 5 people found the following review helpful:
4.0 out of 5 stars Needs better examples, January 3, 1998
By A Customer
This review is from: Thread Time: The MultiThreaded Programming Guide (Paperback)
Best book I've seen on the subject of POSIX thread programming. My only criticism is that the examples are lame. They excercise the API calls described in the preceeding text without adding any helpful context, insight, or details.

The author would have done better to provide one or two fairly complex case studies as examples, with analysis of their design process and tradeoffs. Instead there are small examples of every little detail of the API, that they add nothing of value to the book.

That criticism aside, it is a well-written, useful book, which I highly recommend.

Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


3.0 out of 5 stars A good book., December 22, 2010
By 
Amazon Verified Purchase(What's this?)
This review is from: Thread Time: The MultiThreaded Programming Guide (Paperback)
Pro:
An easy-to-read book meant for practitioners without missing basic multi-threading concepts.
Cons:
- I think they use some sort of scanner that treat tabs and spaces differently; Nothing wrong with that, is just that the code looks messy.
- While the book can be apply to any posix environment, the author was a little bit too comfortable with HP-Unix, again nothing wrong with that, but choosing an agnostic approach could it be the choice for a non-OS MT book.
- Several code examples didn't compile mostly by syntax errors... Not a big deal, but I didn't enjoy extra minutes/hours trying to find the problem of the code.
- Source code files are not standalone examples. I don't mind a code example using code from another file but the files aren't organized and their names aren't trivial so you have to do a brute-force look to each file until you find the code that your example is using.

Overall, even though, I only have one pro, I would recommend this book because I learned a lot from it and it is easy to read. While not a holy-grail, this are one of those that I wish I could it have this book in my undergrad years.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No

Share your thoughts with other customers: Create your own review
 
 
 
Most Recent Customer Reviews


Only search this product's reviews



What Other Items Do Customers Buy After Viewing This Item?


Tags Customers Associate with This Product

 (What's this?)
Click on a tag to find related items, discussions, and people.
 
(1)

Your tags: Add your first tag
 

Sell a Digital Version of This Book in the Kindle Store

If you are a publisher or author and hold the digital rights to a book, you can sell a digital version of it in our Kindle Store. Learn more

Customer Discussions

This product's forum
Discussion Replies Latest Post
No discussions yet

Ask questions, Share opinions, Gain insight
Start a new discussion
Topic:
First post:
Prompts for sign-in
 


Active discussions in related forums
Search Customer Discussions
Search all Amazon discussions
   
Related forums



So You'd Like to...


Create a guide


Look for Similar Items by Category


Look for Similar Items by Subject