Programming with POSIX Threads [NOOK Book]

Overview

With this practical book, you will attain a solid understanding of threads and will discover how to put this powerful mode of programming to work in real-world applications.

The primary advantage of threaded programming is that it enables your applications to accomplish more than one task at the same time by using the number-crunching power of multiprocessor parallelism and by automatically exploiting I/O concurrency in your code, even on a single processor machine. The result: ...

See more details below
Programming with POSIX Threads

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK 7.0
  • Samsung Galaxy Tab 4 NOOK 10.1
  • NOOK HD Tablet
  • NOOK HD+ Tablet
  • NOOK eReaders
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac

Want a NOOK? Explore Now

NOOK Book (eBook)
$51.99
BN.com price
(Save 20%)$64.99 List Price

Overview

With this practical book, you will attain a solid understanding of threads and will discover how to put this powerful mode of programming to work in real-world applications.

The primary advantage of threaded programming is that it enables your applications to accomplish more than one task at the same time by using the number-crunching power of multiprocessor parallelism and by automatically exploiting I/O concurrency in your code, even on a single processor machine. The result: applications that are faster, more responsive to users, and often easier to maintain. Threaded programming is particularly well suited to network programming where it helps alleviate the bottleneck of slow network I/O.

 

This book offers an in-depth description of the IEEE operating system interface standard, POSIXAE (Portable Operating System Interface) threads, commonly called Pthreads. Written for experienced C programmers, but assuming no previous knowledge of threads, the book explains basic concepts such as asynchronous programming, the lifecycle of a thread, and synchronization. You then move to more advanced topics such as attributes objects, thread-specific data, and realtime scheduling. An entire chapter is devoted to "real code," with a look at barriers, read/write locks, the work queue manager, and how to utilize existing libraries. In addition, the book tackles one of the thorniest problems faced by thread programmers-debugging-with valuable suggestions on how to avoid code errors and performance problems from the outset.

 

Numerous annotated examples are used to illustrate real-world concepts. A Pthreads mini-reference and a look at future standardization are also included.

Read More Show Less

Product Details

  • ISBN-13: 9780132702126
  • Publisher: Pearson Education
  • Publication date: 5/29/1993
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 1
  • Pages: 400
  • Sales rank: 1,311,843
  • File size: 19 MB
  • Note: This product may take a few minutes to download.

Meet the Author

David R. Butenhof, a recognized Pthreads authority, was deeply involved in the creation of the IEEE POSIX standard as well as the X/Open threading extensions, which were fast-tracked into X/Open XSH5 (UNIX98). An engineer at Digital Equipment Corporation, he was the lead architect and developer of Digital's own threading architecture and designed and implemented much of the Pthreads interfaces on Digital UNIX 4.0.

0201633922AB04062001

Read More Show Less

Table of Contents



List of Example Programs.


Preface.


Intended Audience.


About the Author.


Acknowledgments.


1. Introduction.

The "Bailing Programmers".

Definitions and Terminology.

Asynchronous.

Concurrency.

Uniprocessor and Multiprocessor.

Parallelism.

Thread Safety and Reentrancy.

Concurrency Control Functions.

Asynchronous Programming is Intuitive...

. . . Because Unix is Asynchronous.

. . . Because the World is Asynchronous.

About the Examples in This Book.

Asynchronous Programming, by Example.

the Baseline, Synchronous Version.

A Version Using Multiple Processes.

A Version Using Multiple Threads.

Summary.

Benefits of Threading.

Parallelism.

Concurrency.

Programming Model.

Costs of Threading.

Computing Overhead.

Programming Discipline.

Harder to Debug.

To Thread or Not to Thread?

POSIX Thread Concepts.

Architectural Overview.

Types and Interfaces.

Checking for Errors.



2. Threads.

Creating and Using Threads.

The Life of a Thread.

Creation.

Startup.

Running and Blocking.

Termination.

Recycling.



3. Synchronization.

Invariants, Critical Sections, and Predicates.

Mutexes.

Creating and Destroying a Mutex.

Locking and Unlocking a Mutex.

Nonblocking Mutex Locks.

Using Mutexes for Atomicity.

Sizing a Mutex to Fit the Job.

Using More Than One Mutex.

Lock Hierarchy.

Lock Chaining.

Condition Variables.

Creating and Destroying a Condition Variable.

Waiting on a Condition Variable.

Waking Condition Variable Waiters.

One Final Alarm Program.

Memory Visibility Between Threads.



4. A Few Ways to Use Threads.

Pipeline.

Work Crew.

Client/Server.



5. Advanced Threaded Programming.

One-Time Initialization.

Attributes Objects.

Mutex Attributes.

Condition Variable Attributes.

Thread Attributes.

Cancellation.

Deferred Cancelability.

Asynchronous Cancelability.

Cleaning Up.

Thread-Specific Data.

Creating Thread-Specific Data.

Using Thread-Specific Data.

Using Destructor Functions.

Realtime Scheduling.

POSIX Realtime Options.

Scheduling Policies and Priorities.

Contention Scope and Allocation Domain.

Problems With Realtime Scheduling.

Priority-Aware Mutexes.

Priority Ceiling Mutexes.

Priority Inheritance Mutexes.

Threads and Kernel Entities.

Many-to-One (User Level).

One-to-One (Kernel Level).

Many-to-Few (Two Level).



6. Posix Adjusts to Threads.

Fork.

Fork Handlers.

Exec.

Process Exit.

Stdio.

Flockfile and Funlockfile.

Getchar_Unlocked and Putchar_Unlocked.

Thread-Safe Functions.

User and Terminal Identification.

Directory Searching.

String Token.

Time Representation.

Random Number Generation.

Group and User Database.

Signals.

Signal Actions.

Signal Masks.

Pthread_Kill.

Sigwait and Sigwaitinfo.

Sigev_Thread.

Semaphores: Synchronizing With a Signal-Catching Function.



7. "Real Code".

Extended Synchronization.

Barriers.

Read-Write Locks.

Work Queue Manager.

But What About Existing Libraries?

Modifying Libraries to Be Thread-Safe.

Living With Legacy Libraries.



8. Hints to Avoid Debugging.

Avoiding Incorrect Code.

Avoid Relying on "Thread Inertia".

Never Bet Your Mortgage on a Thread Race.

Cooperate to Avoid Deadlocks.

Beware of Priority Inversion.

Never Share Condition Variables Between Predicates.

Sharing Stacks and Related Memory Corrupters.

Avoiding Performance Problems.

Beware of Concurrent Serialization.

Use the Right Number of Mutexes.

Too Many Mutexes Will Not Help.

Never Fight Over Cache Lines.



9. Posix Threads Mini-Reference.

POSIX 1003.1cn1995 Options.

POSIX 1003.1cn1995 Limits.

POSIX 1003.1cn1995 Interfaces.

Error Detection and Reporting.

Use of Void* Type.

Threads.

Mutexes.

Condition Variables.

Cancellation.

Thread-Specific Data.

Realtime Scheduling.

Fork Handlers.

Stdio.

Thread-Safe Functions.

Signals.

Semaphores.



10. Future Standardization.

X/Open Xsh5 [Unix98].

POSIX Options for XSH5.

Mutex Type.

Set Concurrency Level.

Stack Guard Size.

Parallel I/O.

Cancellation Points.

POSIX 1003.1j.

Barriers.

Read-Write Locks.

Spinlocks.

Condition Variable Wait Clock.

Thread Abort.

Posix 1003.14.



Bibliography.


Thread Resources on the Internet.


Index. 0201633922T04062001
Read More Show Less

Customer Reviews

Average Rating 5
( 1 )
Rating Distribution

5 Star

(1)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Anonymous

    Posted April 30, 2002

    Great Intro to Threads for Intermediate Level Programmers!

    I found this book to be a very instructive & somewhat comprehensive introduction to using POSIX Threads in UNIX Programming. It has a great introduction, very clear explanation of their structure and use, comprehensive examples of their applications in real computer science programming and computational problems. What sets this book apart is that it is not overly technical and brief in its explanation. Illustrations and metaphors supplement the concept of how threads work together, and the text is very clear to follow along. I would recommend this book to anyone - student or programmer, looking for a solid introduction to threads. This is not a book for people unexperienced in intermediate level programming, or those who do not know the C programming language.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)