Buy New

or
Sign in to turn on 1-Click ordering.
or
Amazon Prime Free Trial required. Sign up when you check out. Learn More
Buy Used
Used - Good See details
$3.80 & eligible for FREE Super Saver Shipping on orders over $25. Details

or
Sign in to turn on 1-Click ordering.
 
   
More Buying Choices
Have one to sell? Sell yours here
Multithreaded Programming With PThreads
 
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.

Multithreaded Programming With PThreads [Paperback]

Bil Lewis (Author), Daniel J. Berg (Author), Sun Microsystems Press (Author)
2.9 out of 5 stars  See all reviews (7 customer reviews)

List Price: $34.95
Price: $23.98 & eligible for FREE Super Saver Shipping on orders over $25. Details
You Save: $10.97 (31%)
  Special Offers Available
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
In Stock.
Ships from and sold by Amazon.com. Gift-wrap available.
Only 2 left in stock--order soon (more on the way).
Want it delivered Thursday, February 2? Choose One-Day Shipping at checkout. Details
Textbook Student FREE Two-Day Shipping for students on millions of items. Learn more


Book Description

0136807291 978-0136807292 December 19, 1997 1

This book will give the UNIX and NT programmer a solid, basic understanding of threads -- and the powerful new POSIX Pthreads library.The book begins with an overview of the need for, and evolution of multithreading. Understand how threads are constructed, and how operating systems like Solaris(r) provide support for them. Learn the fundamentals of thread scheduling and synchronization, understanding the trade-offs involved in using synchronization variables. Learn how to dispose of (cancel) unwanted threads; and manage asynchronous events via signaling. The book includes detailed coverage of writing and compiling multithreaded programs, including sample applications, libraries, design choices, performance optimization and hardware considerations.For all experienced C, UNIX and NT programmers who need to understand the new Pthreads library.


Special Offers and Product Promotions

  • Buy $50 in qualifying physical textbooks, get $5 in Amazon MP3 Credit. Here's how (restrictions apply)

Frequently Bought Together

Multithreaded Programming With PThreads + Pthreads Programming: A POSIX Standard for Better Multiprocessing (O'Reilly Nutshell) + Programming with POSIX® Threads
Price For All Three: $95.61

Show availability and shipping details

Buy the selected items together
  • In Stock.
    Ships from and sold by Amazon.com.
    Eligible for FREE Super Saver Shipping on orders over $25. Details

  • Pthreads Programming: A POSIX Standard for Better Multiprocessing (O'Reilly Nutshell) $25.19

    In Stock.
    Ships from and sold by Amazon.com.
    This item ships for FREE with Super Saver Shipping. Details

  • Programming with POSIX® Threads $46.44

    In Stock.
    Ships from and sold by Amazon.com.
    This item ships for FREE with Super Saver Shipping. Details



Editorial Reviews

Amazon.com Review

Multithreading lets programs do two or more tasks at once, and it can let programmers take advantage of the latest symmetric multiprocessor (SMP) systems in Unix. But to get this performance boost, you'll want to read Multithreaded Programming with Pthreads first. It delivers both the concepts behind multithreaded design along with real-world source code excerpts that show you how to apply the concepts to real-world Unix projects.

This book begins with the evolution of the various libraries that support multithreading. In the ecumenical spirit of Unix, the authors cover all the bases of Portable Operating System Interface for Unix (POSIX) libraries, including Linux, DEC, IBM, HP, and Sun Solaris, and even add-ons to NT and OS/2 for their POSIX support. The authors acknowledge that there may be variations in your version of Unix, but suggest that POSIX threads have good support from most vendors.

The authors then cover the basics of threads and how they run in today's Unix. The authors turn quickly to their implementation in variants of Unix, including Lightweight Processes (LWPs). They then cover the lifecycles of threads and how they are scheduled.

The primary focus in Multithreaded Programming with Pthreads is on how to make threads work together effectively. Multithreading involves a host of design issues, from patterns of how to organize threading in a program (with models such as the Producer/Consumer or the Master/Slave) to how to coordinate work done by multiple threads with facilities such as mutexes, critical sections, semaphores, and more arcane solutions (such as monitors and spin locks). The authors guide the reader to all the possibilities here, including suggestions on program design.

The real-world focus here involves some sample code (in C), a quick tour of the issues in using Pthreads with other programming languages, and some excellent material on benchmarking multithreaded code. The authors' ideas on when to use and when to avoid Pthreads are also useful. Though Pthreads will not work everywhere, they have a lot of potential to enhance the performance of today's software. This technical--and quite engaging--text can show you if Pthreads are in the cards for your next Unix programming project.

From the Inside Flap

Preface

Today, there are three primary sets of multithreading (MT) libraries: the “standards-based” libraries (all of the UNIX¨ implementations and VMS, which are moving to POSIX), the OS/2¨ library, and the Win32 library. (The NT and OS/2 libraries are fairly similar, which should not be too surprising. NT did start life as OS/2, version 2, after all.) Although the APIs and implementations differ significantly, the fundamental concepts are the same. The ideas in this book are valid for all three; the details of the APIs differ. All the specific discussion in this book focuses on the POSIX multithreading model, with comparisons to OS/2 and Win32 throughout.


A frank note about our motivation is in order here. We have slaved away for countless hours on this book because we're propeller-heads who honestly believe that this technology is a superb thing and that the widespread use of it will make the world a better place for hackers like ourselves.


Your motivations for writing MT programs? You can write your programs better and more easily, they'll run faster, and you'll get them to market more quickly, they'll have fewer bugs, you'll have happier programmers, customers, and higher sales. The only losers in this game are the competitors, who will lag behind you in application speed and quality.


MT is here today. It will soon be ubiquitous. As a professional programmer, you have an obligation to understand this technology. It may or may not be appropriate for your current project, but you must be able to make that conclusion yourself. This book will give you what you need to make that decision.


Welcome to the world of the future!


Who Should Use This Book

This book aims to give the programmer or technical manager a solid, basic understanding of threads—what they are, how they work, why they are useful, and some of the programming issues surrounding their use. As an introductory text, it does not attempt a deep, detailed analysis. (At present, there are no deep, detailed analyses!) After reading this book the reader should have a solid understanding of the fundamentals, be able to write credible, modestly complex, threaded programs and have the understanding necessary to analyze their own programs and determine the viability of threading them. This book is written with the experienced C/UNIX programmer in mind. A non-UNIX programmer will find a few of the details unfamiliar, but the concepts clear. A non-C programmer will find the code fragments and API descriptions mildly challenging, though possible to decipher, while the concepts should be clear. A technically minded nonprogrammer should be able to follow most of the concepts and understand the value of threads. A nontechnical person will not get much from this book.


This book does not attempt to explain the usage of the Win32 or OS/2 APIs. It does contrast them to the POSIX API in order to give the POSIX programmer a feeling for what kind of porting issues might be involved when writing to more than one of these libraries.


How This Book Is Organized

Chapter 1, Introduction—In which we discuss the motivation for creating thread libraries, the advent of shared memory multiprocessors, and the interactions between threads and SMP machines. Chapter 2, Concepts—In which the reader is introduced to the basic concepts of multitasking operating systems and of multithreading as it compares to other programming paradigms. The reader is shown reasons why multithreading is a valuable addition to programming paradigms, and a number of examples of successful deployment are presented. Chapter 3, Foundations—In which we introduce to the underlying structures upon which threads are built, the construction of the thread itself, and the operating system support that allows an efficient implementation. Chapter 4, Lifecycle—In which the reader is treated to a comprehensive explanation of the intricacies in the life of a thread—birth, life, and death. Even death by vile cancellation. A small program which illustrates all of these stages concludes the chapter. Chapter 5, Scheduling—In which we explain the myriad details of the different scheduling models and the various alternative choices that could be made, describe context switching in detail, and delve into gruesome detail of the various POSIX options and parameters. There is a light at the end of the tunnel, however. Chapter 6, Synchronization—In which the reader is led on a hunt for the intimidating synchronization variable and discovers that it is not actually as frightening as had been thought. Programs illustrating the basic use of the POSIX primitives are shown. Chapter 7, Complexities—In which a series of more complex synchronization variables and options are presented and the trade-off between them and the simpler ones are discussed. Synchronization problems and techniques for dealing with them conclude the chapter. Chapter 8, TSD—In which an explanation of thread-specific data is provided, its use and some of the implementation details. We note a few places where use of TSD could be made more efficient and a few other optimizations that can be made. Chapter 9, Cancellation—In which we describe the acrimonious nature of some programs and how unwanted threads may be disposed of. The highly complex issues surrounding bounded time termination and program correctness are also covered. A simple conclusion is drawn. Chapter 10, Signals—In which we deal with the various aspects of handling asynchronous events in a multithreaded program. The definitions are given, alternative designs are discussed, and a program illustrating the most complex case is shown. Chapter 11, Details—In which the details of actually writing and compiling an MT program are reviewed. The defined constants are described and methods of dealing with errors are proposed. We note which vendors have made extensions to Pthreads, and where POSIX is headed. Chapter 12, Libraries—In which we explore a variety of operating systems issues that bear heavily upon the usability of the threads library in actual programs. We examine the status of library functions and the programming issues facing them. We look at some design alternatives for library functions. Chapter 13, Design—In which we explore some designs for programs and library functions. Making both programs and individual functions more concurrent is a major issue in the design of these functions. We look at a variety of code examples and the trade-offs between them. Chapter 14, Languages—In which the use of threads in various programming languages is considered and a few minor notes about special features and requirements are made. A number of public Pthreads libraries and some commercial products exist and are noted. Chapter 15, Tools—In which we consider the kinds of new tools that a reader would want when writing a threaded program. An overview of the Solaris tool set is given, as representative of what should be looked for. Chapter 16, Performance—In which we make things faster, look at general performance issues, political performance issues, and thread specific performance issues. We conclude with a discussion of the actual performance of multithreaded NFS. Chapter 17, Hardware—In which we look at the various designs for SMP machines (cache architectures, interconnect topologies, atomic instructions, invalidation techniques) and consider how those designs affect our programming decisions. Some optimization possibilities are looked at. Chapter 18, Examples—In which several complete programs are presented. The details and issues surrounding the way they use threads are discussed and references to other programs on the net are made.


Product Details

  • Paperback: 432 pages
  • Publisher: Prentice Hall; 1 edition (December 19, 1997)
  • Language: English
  • ISBN-10: 0136807291
  • ISBN-13: 978-0136807292
  • Product Dimensions: 9.2 x 6.9 x 0.9 inches
  • Shipping Weight: 1.6 pounds (View shipping rates and policies)
  • Average Customer Review: 2.9 out of 5 stars  See all reviews (7 customer reviews)
  • Amazon Best Sellers Rank: #336,388 in Books (See Top 100 in Books)

More About the Author

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

 

Customer Reviews

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

34 of 36 people found the following review helpful:
3.0 out of 5 stars This book knocks the P out of Pthreads..., March 16, 1999
By A Customer
This review is from: Multithreaded Programming With PThreads (Paperback)
I primarily ordered this book to learn POSIX threading techniques for Unix. Imagine my surprise when the book delved again and again into excessive detail on Win32 and OS/2 implementations of threads.

The book also spent every other paragraph covering problematic features of threads. If I were going to write a handbook for first time handgun owners, I wouldn't spend half the book explaining how you could take a live round, put it in the chamber, pull back the trigger, put the barrell in your mouth, and gently squeeze the trigger, oh by the way "Don't do that!" I would like to have seen a simple explanation of how to properly use threads for several different cases, and let natural selection determine if I was stupid enough to try some of the extreme cases that the book covers in detail.

Perhaps if the Win32, OS/2, and problematic features of threads had been separated out into late chapters, the book would have been readable. As the book is written, I found it hard to maintain a continuous stream of thought with the authors constantly bleating, Touret-like, "You can do this. BUT DON'T DO THAT! And here's how you can do the same thing for Win32. BUT DON'T DO THAT!" The confusing graphic illustrations and lack of substantial code examples concurrent with the topic at hand did not serve to make my reading any easier.

I also did not appreciate the authors' flippant dismissal of real time programming. To paraphrase the book, "We don't know real time, so tough cookie."

Overall, the book was a decent threads primer with good information scattered throughout.

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


14 of 15 people found the following review helpful:
5.0 out of 5 stars Very good book on Pthreads, January 4, 1999
By A Customer
This review is from: Multithreaded Programming With PThreads (Paperback)
This book has all of the information from the "Threads Primer" book and more. It covers the topic very well and if this was the only book you read you'd be fine. I like the Butenhof threads book just a bit better because the programming examples there were much better than the small code fragments presented in this book.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


11 of 12 people found the following review helpful:
1.0 out of 5 stars User of Sun Equipment, writer of parallel software., April 7, 2004
This review is from: Multithreaded Programming With PThreads (Paperback)
As technical books go, this is the second worst book I've ever personally bought - and I have five book cases full of books (mostly technical ones).

The book covers far too much material, in far too small a depth, to be of any use to anyone. Since it's published by Sun Microsystems, whose main operating system is Solaris, I thought there might be a decent coverage of threads on Solaris, with less devoted to NT, Dec and whoever elses. But no, there is as much coverage on Solaris threads, as there is on any other. You could say it's a balanced coverage, but at such a depth to be useless to anyone really. If you need to know about threads on Windows, find a specific book. If you need to know about pthreads, find a better book on pthreads.

Just avoid this book. However Sun Microsystems, a respected producer of hardware and some excellent technical books, published such rubbish I don't know.

Do youself a favor, take a look at 'Multithreaded, Parallel and Distributed Programming' by Gregory R. Andrews. That is a good book on parallel programming, with an indepth discussion about algorithms, and code to implement them in threads, openMP and MPI. It's coverage of algorithms, barriers, locks etc is excellent.

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




Suggested Tags from Similar Products

 (What's this?)
Be the first one to add a relevant tag (keyword that's strongly related to this product).
 
(30)
(27)

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


Listmania!


So You'd Like to...



Look for Similar Items by Category


Look for Similar Items by Subject