You are previewing Interprocess Communications in Linux®: The Nooks & Crannies.
O'Reilly logo
Interprocess Communications in Linux®: The Nooks & Crannies

Book Description

  • The definitive guide to Linux processes and IPC for programmers and system administrators

  • Pipes, message queues, semaphores, shared memory, RPC, sockets, the /proc filesystem, and much more

  • In-depth coverage of multithreading with POSIX compliant LinuxThreads

  • Contains dozens of detailedprogram examples (GNU C/C++ 2.96/Red Hat Linux 7.3 & 8.0)

Raves for Gray's companion UNIX® volume!

"Concepts I only vaguely understood now make complete sense to me! The sample code and exercises are so good,they seem to clamp down on the concepts like a vise grip..."—S. Lee Henry, Johns HopkinsUniversity

The expert, example-rich guide to Linuxprocesses and IPC

Serious Linux software developers need a sophisticated understanding of processes, system level programming andinterprocess communication techniques. Now, John Shapley Gray, author of the widely praised Interprocess Communicationin UNIX, Second Edition, zeroes in on the core techniques Linux uses to manage processes and IPC. With exceptionalprecision and great clarity, Gray explains what processes are, how they're generated, how they access their environments,how they communicate—and how to use them to build robust, high-performance systems.

  • Includes extensive coverage of named/unnamed pipes, message queues, semaphores, and shared memory.

  • Provides C++ classes for System V IPC facilities.

  • Offers an in-depth introduction to socket-basedcommunication.

  • Demystifies Linux's /proc file system.

  • Illuminates the LinuxThreads POSIX threadimplementation and its use in multithreaded applications.

  • Provides valuable tips and warnings, plus insight intokey differences amongst Linux and Unix implementations.

  • Includes problem sets and illustrations designed toreinforce key concepts.

Gray presents dozens of standalone program examples; all compiled with the GNU C/C++ compiler 2.96 & 3.2, and fullytested on PC platforms running Red Hat Linux 7.3 & 8.0.

http://authors.phptr.com/gray/

Table of Contents

  1. Copyright
    1. Dedication
  2. Introduction
  3. Acknowledgments
  4. 1. Programs and Processes
    1. 1.1. Introduction
    2. 1.2. Library Functions
    3. 1.3. System Calls
    4. 1.4. Linking Object Code
    5. 1.5. Managing Failures
    6. 1.6. Executable File Format
    7. 1.7. System Memory
    8. 1.8. Process Memory
    9. 1.9. The u Area
    10. 1.10. Process Memory Addresses
    11. 1.11. Creating a Process
    12. 1.12. Summary
    13. 1.13. Key Terms and Concepts
  5. 2. Processing Environment
    1. 2.1. Introduction
    2. 2.2. Process ID
    3. 2.3. Parent Process ID
    4. 2.4. Process Group ID
    5. 2.5. Permissions
    6. 2.6. Real and Effective User and Group IDs
    7. 2.7. File System Information
    8. 2.8. File Information
    9. 2.9. Process Resource Limits
    10. 2.10. Signaling Processes
    11. 2.11. Command-Line Values
    12. 2.12. Environment Variables
    13. 2.13. The /proc Filesystem
    14. 2.14. Summary
    15. 2.15. Key Terms and Concepts
  6. 3. Using Processes
    1. 3.1. Introduction
    2. 3.2. The fork System Call Revisited
    3. 3.3. exec's Minions
      1. 3.3.1. execlp
      2. 3.3.2. execvp
    4. 3.4. Using fork and exec Together
    5. 3.5. Ending a Process
    6. 3.6. Waiting on Processes
    7. 3.7. Summary
    8. 3.8. Key Terms and Concepts
  7. 4. Primitive Communications
    1. 4.1. Introduction
    2. 4.2. Lock Files
    3. 4.3. Locking Files
    4. 4.4. More About Signals
    5. 4.5. Signal and Signal Management Calls
    6. 4.6. Summary
    7. 4.7. Key Terms and Concepts
  8. 5. Pipes
    1. 5.1. Introduction
    2. 5.2. Unnamed Pipes
    3. 5.3. Named Pipes
    4. 5.4. Summary
    5. 5.5. Key Terms and Concepts
  9. 6. Message Queues
    1. 6.1. Introduction
    2. 6.2. IPC System Calls: A Synopsis
    3. 6.3. Creating a Message Queue
    4. 6.4. Message Queue Control
    5. 6.5. Message Queue Operations
    6. 6.6. A Client–Server Message Queue Example
    7. 6.7. Message Queue Class
    8. 6.8. Summary
    9. 6.9. Key Terms and Concepts
  10. 7. Semaphores
    1. 7.1. Introduction
    2. 7.2. Creating and Accessing Semaphore Sets
    3. 7.3. Semaphore Control
      1. 7.3.1. Semaphore Control Details
    4. 7.4. Semaphore Operations
      1. 7.4.1. Semaphore Operation Details
    5. 7.5. Semaphore Class
    6. 7.6. Summary
    7. 7.7. Key Terms and Concepts
  11. 8. Shared Memory
    1. 8.1. Introduction
    2. 8.2. Creating a Shared Memory Segment
    3. 8.3. Shared Memory Control
    4. 8.4. Shared Memory Operations
    5. 8.5. Using a File as Shared Memory
    6. 8.6. Shared Memory Class
    7. 8.7. Summary
    8. 8.8. Key Terms and Concepts
  12. 9. Remote Procedure Calls
    1. 9.1. Introduction
    2. 9.2. Executing Remote Commands at a System Level
    3. 9.3. Executing Remote Commands in a Program
    4. 9.4. Transforming a Local Function Call into a Remote Procedure
    5. 9.5. Debugging RPC Applications
    6. 9.6. Using RPCGEN to Generate Templates and a MAKEFILE
    7. 9.7. Encoding and Decoding Arbitrary Data Types
    8. 9.8. Using Broadcasting to Search for an RPC Service
    9. 9.9. Summary
    10. 9.10. Key Terms and Concepts
  13. 10. Sockets
    1. 10.1. Introduction
    2. 10.2. Communication Basics
      1. 10.2.1. Network Addresses
      2. 10.2.2. Domains—Network and Communication
      3. 10.2.3. Protocol Families
      4. 10.2.4. Socket Types
    3. 10.3. IPC Using Socketpair
    4. 10.4. Sockets: The Connection-Oriented Paradigm
      1. 10.4.1. A UNIX Domain Stream Socket Example
      2. 10.4.2. An Internet Domain Stream Socket Example
    5. 10.5. Sockets: The Connectionless Paradigm
      1. 10.5.1. A UNIX Domain Datagram Socket Example
      2. 10.5.2. An Internet Domain Datagram Socket Example
    6. 10.6. Multiplexing I/O with select
    7. 10.7. Peeking at Data
    8. 10.8. Out of Band Messages
    9. 10.9. Summary
    10. 10.10. Key Terms and Concepts
  14. 11. Threads
    1. 11.1. Introduction
    2. 11.2. Creating a Thread
    3. 11.3. Exiting a Thread
    4. 11.4. Basic Thread Management
    5. 11.5. Thread Attributes
    6. 11.6. Scheduling Threads
    7. 11.7. Using Signals in Threads
    8. 11.8. Thread Synchronization
      1. 11.8.1. Mutex Variables
      2. 11.8.2. Condition Variables
      3. 11.8.3. Read/Write Locks
      4. 11.8.4. Multithread Semaphores
    9. 11.9. Thread-Specific Data
    10. 11.10. Debugging Multithreaded Programs
    11. 11.11. Summary
    12. 11.12. Nomenclature and Key Concepts
  15. A. Using Linux Manual Pages
    1. A.1. Manual Page Sections
    2. A.2. Manual Page Format
    3. A.3. Standard Linux System Calls
  16. B. UNIX Error Messages
  17. C. RPC Syntax Diagrams
    1. C.1. Introduction
    2. C.2. RPC Definitions
      1. C.2.1. Program-Definition
        1. C.2.1.1. Version
        2. C.2.1.2. Procedure
      2. C.2.2. Const-Definition
      3. C.2.3. Enum-Definition
        1. C.2.3.1. Enum-Value-List
        2. C.2.3.2. Enum value
      4. C.2.4. Typedef-Definition
        1. C.2.4.1. Declaration
        2. C.2.4.2. Simple Declaration
        3. C.2.4.3. Fixed-Array Declaration
        4. C.2.4.4. Variable-Array Declaration
        5. C.2.4.5. Pointer Declaration
      5. C.2.5. Structure-Definition
      6. C.2.6. Union-Definition
        1. C.2.6.1. Case-List
    3. C.3. RPC Keywords
    4. C.4. Some RPC Examples
  18. D. Profiling Programs
    1. D.1. Introduction
    2. D.2. Sample Program for Profiling
    3. D.3. Generating Profile Data
    4. D.4. Viewing and Interpreting Profile Data
  19. E. Bibliography