You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Processes I<br />
8. PROCESSES (I)<br />
Process Subsystem Details<br />
In <strong>Unix</strong>, a process is <strong>the</strong> execution of a program and consists of a pattern of bytes containing:<br />
- machine instructions (text)<br />
- data<br />
- stack<br />
Several processes may all be instances of one program.<br />
Processes follow sets of instructions of <strong>the</strong>ir own and not of o<strong>the</strong>rs and may not read or write data or stack of<br />
ano<strong>the</strong>r process.<br />
Processes<br />
- Created by "fork" system call (all except process 0)<br />
- Invoking process: parent<br />
- New Process: child<br />
- Every process has one parent, but parent may have many children.<br />
- Kernel identifies files by process ID (PID)<br />
- Process 0 created "by hand" at boot. After "forking" a child process, it becomes <strong>the</strong> 'swapper". Its child is<br />
called "init".<br />
- "init" is <strong>the</strong> ancestor of all o<strong>the</strong>r processes on <strong>the</strong> system.<br />
- When a user compiles a source program, an executable file is created which contains:<br />
- Set of headers describing <strong>the</strong> attributes of <strong>the</strong> file<br />
- Program text<br />
- Initialized data and an indication of <strong>the</strong> space needed for uninitialized data<br />
- o<strong>the</strong>r sections e.g.: symbol table info.<br />
Executables<br />
- Image, etc. loaded into memory during an 'exec' system call.<br />
- When loaded, consists of 3 "regions":<br />
- Text<br />
- Data<br />
- Stack<br />
- Process has 2 stacks: 1 for user mode, 1 for kernel mode<br />
- Processes enter kernel mode by executing "trap" instruction which causes a hardware mode switch.<br />
Kernel Process Table<br />
- One entry per process<br />
- Each process is allocated a "u_area" which contains private data manipulated only by <strong>the</strong> kernel.<br />
- This points to a "per process region table" which points to a "region table".<br />
- A region is a contiguous area of a process's addressable space ( i.e.: text, data, stack).<br />
- Extra indirection is in place so that data spaces may be "shared" between processes<br />
- Process table entry and u area entry contain <strong>the</strong> control and status information for a process. The u area is<br />
basically an extension of <strong>the</strong> process table.<br />
- u_area info is only needed when <strong>the</strong> process is executing.<br />
- Process table entries are needed by <strong>the</strong> scheduler.<br />
Context of a Process<br />
- Process's state:<br />
- Text<br />
- Values of global user variables and data structures<br />
- Values of machine registers<br />
- Values in its process table entry and its u_area<br />
- Contents of its user and kernel stacks<br />
- "Context switch" change of active process.<br />
- Interrupts are handled in <strong>the</strong> context of <strong>the</strong> current process, not necessarily <strong>the</strong> originator.<br />
93