YouTube placeholder

The Process Abstraction

Operating System Abstractions

Abstractions simplify application design by:
  • hiding undesirable properties,

  • adding new capabilities, and

  • organizing information.

Abstractions provide an interface to application programmers that separates policy—what the interface commits to accomplishing—​from mechanism—how the interface is implemented.

Example Abstraction: File

What undesirable properties do file systems hide?
  • Disks are slow!

  • Chunks of storage are actually distributed all over the disk.

  • Disk storage may fail!

What new capabilities do files add?
  • Growth and shrinking.

  • Organization into directories.

What information do files help organize?
  • Ownership and permissions.

  • Access time, modification time, type, etc.

Preview of Coming Abstractions

  • Threads abstract the CPU.

  • Address spaces abstract memory.

  • Files abstract the disk.

  • We will return to these abstractions. We are starting with an organizing principle.

thread

addressspace

file

The Process

Processes are the most fundamental operating system abstraction.
  • Processes organize information about other abstractions and represent a single thing that the computer is "doing."

  • You know processes as app(lication)s.

Organizing Information

Unlike threads, address spaces and files, processes are not tied to a hardware component. Instead, they contain other abstractions.

Processes contain:
  • one or more threads,

  • an address space, and

  • zero or more open file handles representing files.

process
Figure 2. The Process

Process as Protection Boundary

The operating system is responsible for isolating processes from each other.

  • What you do in your own process is your own business but it shouldn’t be able to crash the machine or affect other processes—or at least processes started by other users.

  • Thus: safe intra-process communication is your problem; safe inter-process communication is an operating system problem.

Intra-Process Communication: Easy

intraprocess
  • Communication between multiple threads in a process is usually accomplished using shared memory.

  • Threads within a process also share open file handles and both static and dynamically-allocated global variables.

  • Thread stacks and thus thread local variables are typically private.

Intra-Process Communication: Easy…​ Maybe

intraprocess
  • Sharing data requires synchronization mechanisms to ensure consistency.

  • We will return to this later.

Inter-Process Communication: Harder

interprocess
  • A variety of mechanism exist to enable inter-process communication (IPC), including shared files or sockets, exit codes, signals, pipes and shared memory.

  • All require coordination between the communicating processes.

  • Most have semantics limiting the degree to which processes can interfere with each other.

    • A process can’t just send a SIGKILL to any other process running on the machine!

$ wait # IPC: return codes

returncode
  • Simplest and most-limited form of IPC.

  • Allows processes to return a single int to the process that created them.

  • 0 typically indicates success; non-0, failure.

  • Analogous to older computers that would transform a set of punch cards into a "result."

  • bash exposes return codes as $?:

returncode bash

$ p | pes # IPC: pipes

pipes
  • Pipes create a producer-consumer buffer between two processes.

  • Allows the output from one process to be used as the input to another.

  • The operating system manages a queue for each pipe to accommodate different input and output rates.

  • Facilitates the canonical chaining together of small UNIX utilities to do more sophisticated processing.


Created 2/17/2017
Updated 9/18/2020
Commit 4eceaab // History // View
Built 2/2/2017 @ 19:00 EDT