Operating Systems Lecture Notes
2014 September 9 • Processes
Outline
Process management.
The hardware process.
The abstract machine.
The process abstraction.
Programs and Processes
A program by itself is an unexecutable entity.
Execution requires far more than just the code.
A
process
is the abstraction of an executing program.
The central abstraction implemented by an OS.
Hardware Abstraction
To the hardware, a user looks like a process.
What does the hardware look like to the user and process?
An
abstract machine
is the OS's hardware representation
Abstract Machines
A process (conceptually) executes in a abstract machine.
Each process has an abstract machine, or
processes share an abstract machine.
It depends on what the OS implements.
Think of an abstract machine as a custom hardware system.
“Custom” comes from abstraction.
For example, hide or reveal multiple CPUs.
The System-Call Interface
What does an abstract machine look like?
A abstract machine presents a system-call interface to processes (and users).
A
system-call interface
is a set of procedure-like prototypes.
ssize_t read(int f, void * b, size_t n);
Each prototype is a
system call
.
Different system-call interfaces are different abstract machines.
The Process Abstraction
What does a process look like?
A process is a bag of (almost) all resources needed by a computation.
The missing resource is the CPU.
A process also has other points of view.
A protection boundry.
A (large-grained) scheduling unit.
A smaller piece of a larger computation.
Process Managers
The
process manager
is the part of the OS responsible for implementing processes.
Creating (and destroying) the abstraction.
Setting the hardware to establish process characteristics.
Address spaces, for example.
Managing the interaction between processes and the other resources.
Mainly scheduling, but also other coordination.
Queueing-Diagram Example
The Abstract Machine
The abstract machine is defined by what the hardware provides and the way the OS represents it.
The OS can ignore features that exist or simulate features that don’t.
The end result is the system-call interface.
Different OSs provide different system-call interfaces.
The same OS may provide different system-call interfaces.
The System Call
A system call may look like a procedure, but it’s not.
A system call transfers control from the user’s process to the OS.
Regular procedures stay in the the user’s process (or at least out of the OS).
The control transfer is provided by hardware.
CPU Multiplexing
Process Implementation
A process is a bag of resources. How’s it implemented?
A stuct of fields, each field representing a particular resource.
A struct instance is called a
process descriptor
(or
process control block
or
task control block
or …).
There are alternate implementations.
The Process Table
Process descriptors are usually stored in an array called the
process table
.
A
process ID
is an index into the process table.
There are alternate implementations here too.
Usually a level of indirection between the table and the entries.
PCB Example
A
process
(or
task
)
control block
(
PCB
).
One PCB per process.
Computation State
A computation’s life:
A computation can be in one of three states.
Unexecuted, executing, or done executing.
A computation’s state characterizes
What the computation is currently doing.
What the computation could be doing.
Process State
A computation’s state is called the
process state
.
Even though the process is passive.
The OS designer determines the
set of possible process states and
the way process in one state can go to another state.
Process states and state changes are a useful way to understand an OS.
State Transitions
A change in process state is called a
process-state transition
.
Process-state transitions are caused by
actions taken by the process or
actions internal to the OS.
Process actions include system calls and illegal-address (seg-fault) exceptions.
OS internal actions include timer expiry or power-off interrupts.
Process-State Diagrams
An OS’s process states and transitions can be modeled as a directed, labeled graph called a
process-state diagram
.
The nodes are the process states.
The edges are the transitions.
The edge labels are the actions causing the transition.
The unexecuted and done executing states are usually omitted.
State-Diagram Example
Inter-Process Relations
What’s the relation between two processes executing in a system?
Security says “none”; each is isolated from the other, as it should be.
That answer may be too strict.
Groups of processes may want to cooperate.
Other structure (hierarchies) may simplify process management.
Process Hierarchy
One processes running another leads to a tree hierarchy.
The parent creates the children.
An OS can maintain this hierarchy using pointers to process descriptors.
Hierarchy Management
Processes can share control and data along hierarchy lines.
Control sharing occurs through the process’s lifetime.
Data sharing is usually done only at child-create time.
The OS can off-load to the parent some management responsibilities.
Hierarchy Problems
Sharing along indirect or non-existent lines is hard.
Two siblings sharing with each other.
Establishing dynamic sharing patterns is hard.
An on-going role-playing game.
Summary
A process is a program in execution.
A process is a bag of resources needed by a program to execute.
Except for one important resource.
This page last modified on 2014 September 10.