CIS 307: Processes
This is a quick note.
The information is available in Tanenbaum (chapter 2).
Here is a diagram that represents the states of a process:
Here are some reasons for each possible transition:
- Create
- A process is created by an existing process (parent/child); a process
is created by a service, or as a new batch job, or an interactive logon.
- Terminate
- Normal completion (exit); External completion (forced completion:
by operator, by parent); Internal completion (error, time overrun)
- Schedule
- A process is selected out of the ready queue (is scheduled) and dispatched
to the running state.
- Suspend
- A process starts a time consuming IO operation, or is swapped out, or
makes a spontaneous request to sleep, or is blocked in a synchronization
operation. When a process is suspended, it is on some queue, namely the queue
of all the processes waiting for the same resource. Processes during their
life move from queue to queue, with stays in the running state.
- Continue
- The inverse of Suspension: the resource requested becomes available
(timer, IO completes, unblocking)
- Preempt
- The running process is preempted because some other process of higher
priority has become ready (or it yields)
Fundamental Scheduling Law: A process cannot run if there is a ready process
of higher priority
The kernel keeps track in tables of information about processes and resources:
- Memory
- Memory tables with information about allocation of main/secondary memory
to processes.
- Devices
- IO tables with the status of devices.
- Files
- File tables with information about open files.
- Processes
- Process tables with the Process Control Blocs (PCBs) with information about
process images (User Data + user programs + system stack + PCB)
- IPC
- Information on the state of Inter Process Communication facilities.
If we think of the kernel as a Reactive System, the various tables mentioned
above constitue the State used by the kernel to decide what to do.
We have the following figure:
The commands are service requests from the user programs or from the hardware.
The selected command, and the current (table) state determines the response
and the new state (updated table content).
The Process Control Block (PCB) contains the information required to restart
a suspended process. It includes:
- Identifiers
- Process id, parent id, user id, group id, ..
- Accounting Information
- Information about uses of resources, like compute time, elapsed time,
number of IO operations, ..
- Processor State
- General Purpose Registers (GPRs), Control and status registers, stack
pointers, Virtual memory registers, ..
- Process Control Information
- Scheduling and state information, process privileges and rights,
interprocess communication resources in use, ..
Context, Context Switch
By Context it is usually meant the hardware information automatically
saved/restored in case of an interrupt. A Context Switch is then
the saving or restoring of a context.
Process Switch
When control moves from one process to another we have a Process Switch,
it involves the switch of information (the PCB) that includes context but
is more extensive. Some of the cost of switching from one process to another
is not immediately visible: the system may need to replace the content
of the translation lookaside buffer (TLB) and of the caches. This can be
quite time consuming (hundreds of microseconds).
ingargiola.cis.temple.edu