- Forward


Interprocess Communications
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Review
Back SMYC Forward
  • Process:
    • An instance of a program execution
  • Associated with a Process:
    • ID
    • Memory containing text/instructions, initialized data, unintialized data, stack and heap
    • Arguments to main()
    • Environment
Motivation
Back SMYC Forward
  • Independent Processes:
    • Many processes are completely independent/unrelated
    • A child process generally only starts as a copy of its parent
  • Processes Can Communicate through the File System:
    • A child process has a copy of its parent's file descriptors
    • Different processes may open the same files
  • We Often Also Want Processes To:
    • Coordinate their actions
    • Exchange information other than through the file system
Signals
Back SMYC Forward
  • Purpose:
    • Interrupt the normal flow of execution
  • Use:
    • Notify a process that an event has occurred
  • A Hardware Analogy:
    • Exceptions/Interrupts
Data Transfer Mechanisms
Back SMYC Forward
  • What Happens:
    • Processes transfer data through the kernel space
  • How They Works
    • One process transfers data from user memory to kernel memory (usually referred to as a write)
    • One process transfers data from kernel memory to user memory (usually referred to as a read)
Types of Data Transfer Mechanisms
Back SMYC Forward
  • Byte Stream:
    • The exchange involves an undelimited byte stream as with files (hence one process writes an arbitrary number of bytes and the other reads an arbitrary number of bytes)
    • Examples include pipes, FIFOs (aka named-pipes), and stream sockets
  • Message Oriented:
    • The exchange involves coherent messages that can't be decomposed (hence one process writes a whole message and the other reads a whole message)
    • Examples include message queues and datagram sockets
Other Characteristics of Data Transfer Mechanisms (cont.)
Back SMYC Forward
  • Destructive:
    • In some cases, a read operation "consumes" the data (i.e., the data become unavailable to other readers)
  • Blocking:
    • In some cases, the reader blocks if the data are not available
Shared Memory Mechanisms
Back SMYC Forward
  • What Happens:
    • Multiple processes share memory
  • How It Works:
    • The kernel makes page-table entries in each process point to the same pages of memory
Shared Memory Mechanisms (cont.)
Back SMYC Forward
  • Properties:
    • Fast
    • Require synchronization to avoid conflicts
    • Non-destructive (i.e., data in shared memory is visible to all processes that share it)
  • Examples:
    • Shared memory, memory mappings (including anonymous mappings and mapped files)
Synchronization Mechanisms
Back SMYC Forward
  • Purpose:
    • Allow processes to coordinate their actions
  • Kinds of Uses:
    • Coordinate other kinds of information exchange (e.g., updating shared memory, updating a file)
    • Coordinate steps in an algorithm
Synchronization Mechanisms (cont.)
Back SMYC Forward
  • Semaphores:
    • A non-negative integer that is maintained by the kernel that can be used in a vareity of different ways
  • File Locks:
    • Read locks can be shared; write locks are exclusive (i.e., only one process can hold a write lock on a file/region)
Accessibility of IPC Mechanisms
Back SMYC Forward
  • The Question:
    • What permission/access scheme is used to govern which processes have access to the entity used by the IPC mechanism?
  • Schemes:
    • Related processes only
    • Permission masks
    • Other
Persistence of IPC Mechanisms
Back SMYC Forward
  • The Question:
    • What is the lifetime of the entity used by the IPC mechanism?
  • Lifetimes:
    • Process Persistence - the entity remains in existence only as long as it is held open by at least one process
    • Kernel Persistence - the entity exists until it is explicitly deleted or the system is shut down
    • File System Persistence - the entity exists until it is explicitly deleted (even if the system is shut down and restarted)
Properties of IPC Mechanisms
Back SMYC Forward
ipc-mechanisms
There's Always More to Learn
Back -