Figure 2.2:
A UNIX Process Context
|
The operating system must know specific information about
processes in order to manage and control them. Such information is
usually grouped into two categories:
- process state information
- CPU registers (general purpose and special purpose); used by the process will include:
- memory access registers such as a stack pointer and a heap pointer, a stack frame pointer (points at a data block on the stack holding data exchanged between caller and callee functions),
- a processor status register, possibly a register to hold return addresses,
- program counter; this is a pointer to the program memory (text) location where the next instruction for this process resides
- process control information
- scheduling priority, this describes the rules enforced when determining access to a processor by this process, and can include the identity of the ``process ready to run'' queue that this process is placed in when it is ready to take CPU time
- resource use information, this information records the use of CPU time, elapsed time, process identity number, user or account identity number, etc.
- I/O status information, this can include a list of I/O devices used by the process, a list of open files and any buffers associated with them
- memory allocated, this can describe the region of memory in use (a base address and a size), the page tables (a description of which pieces of memory are ``mapped'' into the single region used by the process)
- This collection of process information is represented in the operating system by a data structure element called process control block (PCB) or a task control block. Consists of:
- An executable program (code), which is usually referred to as the text section
- Associated data needed by the program (global data, stack)
- the global data variables and constants, which are usually referred to as the data section
- the dynamic storage memory used to hold temporary variables and pass function call arguments and results, usually referred to as the stack
- the dynamic storage memory used by C++ new/delete operators and C calls to malloc()/free(), usually referred to as the heap
- Execution context (or state) of the program;
- contents of data registers,
- program counter,
- stack pointer state (waiting on an event?),
- memory allocation,
- status of open files,
Figure 2.3:
Process Control Block (PCB), Processes from main memory to registers.
|
2004-05-25