Pthreads Programming: A Posix Standard for Better Multiprocessing (Paperback)

Dick Buttlar, Jacqueline Farrell, Bradford Nichols

  • 出版商: O'Reilly
  • 出版日期: 1996-10-08
  • 定價: $1,400
  • 售價: 9.5$1,330
  • 貴賓價: 9.0$1,260
  • 語言: 英文
  • 頁數: 286
  • 裝訂: Paperback
  • ISBN: 1565921151
  • ISBN-13: 9781565921153
  • 相關分類: Operating-system程式語言
  • 立即出貨 (庫存 < 3)



Computers are just as busy as the rest of us nowadays. They have lots of tasks to do at once, and need some cleverness to get them all done at the same time.That's why threads are seen more and more often as a new model for programming. Threads have been available for some time. The Mach operating system, the Distributed Computer Environment (DCE), and Windows NT all feature threads.One advantage of most UNIX implementations, as well as DCE, is that they conform to a recently ratified POSIX standard (originally 1003.4a, now 1003.1c), which allows your programs to be portable between them. POSIX threads are commonly known as pthreads, after the word that starts all the names of the function calls. The standard is supported by Solaris, OSF/1, AIX, and several other UNIX-based operating systems.The idea behind threads programming is to have multiple tasks running concurrently within the same program. They can share a single CPU as processes do, or take advantage of multiple CPUs when available. In either case, they provide a clean way to divide the tasks of a program while sharing data.A window interface can read input on dozens of different buttons, each responsible for a separate task. A network server has to accept simultaneous calls from many clients, providing each with reasonable response time. A multiprocessor runs a number-crunching program on several CPUs at once, combining the results when all are done. All these kinds of applications can benefit from threads.In this book you will learn not only what the pthread calls are, but when it is a good idea to use threads and how to make them efficient (which is the whole reason for using threads in the first place). The authors delves into performance issues, comparing threads to processes, contrasting kernel threads to user threads, and showing how to measure speed. He also describes in a simple, clear manner what all the advanced features are for, and how threads interact with the rest of the UNIX system.Topics include:

  • Basic design techniques
  • Mutexes, conditions, and specialized synchronization techniques
  • Scheduling, priorities, and other real-time issues
  • Cancellation
  • UNIX libraries and re-entrant routines
  • Signals
  • Debugging tips
  • Measuring performance
  • Special considerations for the Distributed Computing Environment (DCE)


電腦現在和我們一樣忙碌。它們需要同時處理許多任務,並需要一些巧妙的方法來同時完成這些任務。這就是為什麼線程越來越被視為一種新的編程模型。線程已經存在一段時間了。Mach操作系統、分散式計算環境(DCE)和Windows NT都支持線程。大多數UNIX實現(以及DCE)的一個優點是它們符合最近通過的POSIX標準(最初是1003.4a,現在是1003.1c),這使得您的程序可以在它們之間移植。POSIX線程通常被稱為pthread,這是所有函數調用名稱的開頭詞。該標準得到Solaris、OSF/1、AIX和其他幾個基於UNIX的操作系統的支持。線程編程的思想是在同一個程序中同時運行多個任務。它們可以像進程一樣共享單個CPU,也可以在有多個CPU時利用多個CPU。無論哪種情況,它們都提供了一種清晰的方法來劃分程序的任務並共享數據。窗口界面可以讀取數十個不同按鈕上的輸入,每個按鈕負責一個獨立的任務。網絡服務器必須同時接受來自多個客戶端的呼叫,並為每個客戶端提供合理的響應時間。多處理器可以同時在多個CPU上運行數據計算程序,並在所有計算完成後結合結果。所有這些應用程序都可以從線程中受益。在本書中,您將學習不僅pthread調用是什麼,還要了解何時使用線程以及如何使它們高效(這是使用線程的主要原因)。作者深入探討了性能問題,將線程與進程進行了比較,對比了內核線程和用戶線程,並展示了如何測量速度。他還以簡單明瞭的方式描述了所有高級功能的用途,以及線程如何與UNIX系統的其他部分交互。主題包括:基本設計技巧、互斥鎖、條件和特殊的同步技術、調度、優先級和其他實時問題、取消、UNIX庫和可重入例程、信號、調試技巧、性能測量、分散計算環境(DCE)的特殊考慮。