Practical UNIX Programming:
A Guide to Concurrency, Communication, and Multithreading

by Kay. A. Robbins and Steven Robbins
Prentice Hall, 1996



Table of Contents


I Fundamentals

1 What is Concurrency?

1.1 Multiprogramming and Multitasking
1.2 Concurrency at the Applications Level
1.3 UNIX Standards
1.4 Programming in UNIX
1.5 Making Functions Safe
1.6 Exercise: Argument Arrays
1.7 Additional Reading

2 Programs and Processes

2.1 Layout of a Program Executable
2.2 Static Objects
2.3 The Process ID
2.4 The Process State
2.5 Process Creation and the UNIX fork
2.6 The wait System Call
2.7 The exec System Call
2.8 Background Processes and Daemons
2.9 The Process Environment
2.10 Process Termination in UNIX
2.11 Critical Sections
2.12 Exercise: Process Chains
2.13 Exercise: Process Fans
2.14 Exercise: Simple biff
2.15 Exercise: News biff
2.16 Additional Reading

3 Files

3.1 Directories and Paths
3.2 UNIX File Representation
3.3 File Handle Representation
3.4 Filters and Redirection
3.5 Pipes
3.6 Reading to and Writing from Files
3.7 Nonblocking I/O
3.8 The select call
3.9 FIFOs
3.10 Special Files --- The Audio Device
3.11 Exercise: Traversing Directories
3.12 Exercise: proc Filesystem
3.13 Exercise: Audio
3.14 Exercise: Terminal Control
3.15 Additional Reading

4 Project: The Token Ring

4.1 Forming a Ring
4.2 Simple Communication
4.3 Mutual Exclusion with Tokens
4.4 Mutual Exclusion by Voting
4.5 Leader Election on an Anonymous Ring
4.6 Token Ring for Communication
4.7 A Pipelined Preprocessor
4.8 Parallel Ring Algorithms
4.9 The Flexible Ring
4.10 Additional Reading


II Asynchronous Events

5 Signals

5.1 Sending Signals
5.2 The Signal Mask and Signal Sets
5.3 Catching and Ignoring Signals --- sigaction
5.4 Waiting for Signals --- pause and sigsuspend
5.5 An Example --- biff
5.6 System Calls and Signals
5.7 siglongjmp and sigsetjmp
5.8 Realtime Signals
5.9 Asynchronous I/O
5.10 Exercise: Dumping Statistics
5.11 Exercise: proc Filesystem II
5.12 Exercise: Spooling a Slow Device
5.13 Additional Reading

6 Project: Timers

6.1 Times in UNIX
6.2 Interval Timers
6.3 Project Overview
6.4 Simple Timers
6.5 Setting One of Five Single Timers
6.6 Multiple Timers
6.7 A Robust Implementation of Multiple Timers
6.8 mycron, a Small Cron Facility
6.9 POSIX Timer Implementation
6.10 Additional Reading

7 Project: Cracking Shells

7.1 A Simple Shell
7.2 Redirection
7.3 Pipelines
7.4 Signals
7.5 Process Groups, Sessions, and Controlling Terminals
7.6 Handling Background Processes in ush
7.7 Job Control
7.8 Exercise: Job Control for ush
7.9 Additional Reading


III Concurrency

8 Critical Sections and Semaphores

8.1 Critical Sections and Atomic Operations
8.2 Semaphores
8.3 Semaphores in POSIX
8.4 Semaphores in System V (Spec 1170)
8.5 Semaphores and Signals
8.6 Exercise: POSIX Unnamed Semaphores
8.7 Exercise: POSIX Named Semaphores
8.8 Exercise: License Manager
8.9 Exercise: System V Shared Memory
8.10 Exercise: System V Message Queues
8.11 Additional Reading

9 POSIX Threads

9.1 A Motivating Problem: Monitoring File Descriptors
9.2 POSIX Threads
9.3 Basic Thread Management
9.4 User Versus Kernel Threads
9.5 Thread Attributes
9.6 Exercise: Parallel File Copy
9.7 Additional Reading

10 Thread Synchronization

10.1 Mutexes
10.2 Semaphores
10.3 Condition Variables
10.4 Signal Handling and Threads
10.5 Exercise: Threaded Print Server
10.6 Additional Reading

11 Project: The Not Too Parallel Virtual Machine

11.1 The Not Too Parallel Virtual Machine
11.2 NTPVM Project Overview
11.3 I/O and Testing of Dispatcher
11.4 Single Task with No Input
11.5 Sequential Tasks
11.6 Concurrent Tasks
11.7 Broadcast and Barriers
11.8 Termination and Signals
11.9 Additional Reading


IV Communication

12 Client-Server Communication

12.1 Client-Server Strategies
12.2 The Universal Internet CommunicationInterface (UICI)
12.3 Network Communication
12.4 Socket Implementation of UICI
12.5 Transport Layer Interface --- TLI
12.6 STREAMS
12.7 STREAMS Implementation of UICI
12.8 Reentrant UICI
12.9 Exercise: Transmission of Audio
12.10 Exercise: Ping Server
12.11 Additional Reading

13 Project: Internet Radio

13.1 Overview of the Multiplexer
13.2 One-way Communication
13.3 Two-way Communication
13.4 The Transmit Buffer
13.5 Multiplexing the Transmit Buffer
13.6 Network Receivers
13.7 Tuning In and Out
13.8 Network Broadcaster
13.9 Signal Handling
13.10 Additional Reading

14 Remote Procedure Calls

14.1 Basic Operation
14.2 Converting a Simple Local Call to an RPC
14.3 An Improved Remote Random Number Service
14.4 Server State and Idempotent Requests
14.5 Remote Idempotent File Service
14.6 Binding and Naming of Services
14.7 Failures
14.8 NFS --- Network File System
14.9 Threads and Remote Procedure Calls
14.10 Exercise: Stateless File Server
14.11 Additional Reading

15 Project: Tuple Space

15.1 Linda
15.2 Richard, a Simplified Linda
15.3 A Simple Richard Tuple Space
15.4 Blackboards: a Tuple Space Application
15.5 Active Tuples
15.6 Tuple Spaces as Tuples
15.7 A Multithreaded Server
15.8 Additional Reading



A UNIX Fundamentals

A.1 Getting Help
A.2 Compilation
A.3 Makefiles
A.4 Header Files
A.5 Linking and Libraries
A.6 Debugging Aids
A.7 User Environment
A.8 Additional Reading

B UICI Implementation

B.1 UICI Prototypes
B.2 Streams Implementation
B.3 Socket Implementation
B.4 TLI Implementation
B.5 Reentrant UICI Implementation


Bibliography



Index



Back to home page