3.1 Process: A Definition

A process is a unit of work created by the operating system. It is important to note that processes and programs are not necessarily equivalent. A program may consist of multiple processes. In some situations, a process might not be associated with any particular program. Processes are artifacts of the operating system and programs are artifacts of the developer. Current operating systems such as UNIX/Linux are capable of managing hundreds or even thousands of concurrently loaded processes.

In order for a unit of work to be called a process it must have an address space assigned to it by the operating system. It must have a process id. It must have a state and an entry in the process table. According to the POSIX standard, it must have one or more flows of controls executing within that address space and the required system resources for those flows of control. A process has a set of executing instructions that reside in the address space of that process. Space is allocated for the instructions, any data that belongs to the process, and stacks for function calls and local variables .

3.1.1 Two Kinds of Processes

When a process executes, the operating system assigns the process to a processor. The process executes its instructions for a period a time. The process is preempted so another process can be assigned the processor. The operating system scheduler switches between the code of one process, user , or system to the code of another process, giving each process a chance to execute their instructions. There are user and system processes. Processes that execute system code are called system processes. System processes administer to the whole system. They perform housekeeping tasks such as allocating memory, swapping pages of memory between internal and secondary storage, checking devices, and so on. They also perform tasks on behalf of the user processes such as fulfill I/O requests , allocate memory, and so on. User processes execute its own code and sometimes they make system function calls. When a user process executes its own code, it is in user mode . In user mode , the process cannot execute certain privileged machine instructions. When a user process makes a system function call, for example read() , write() , open () , it is executing operating system instructions. What occurs is the user process is put on hold until the system call has completed. The processor is given to the kernel to complete the system call. At that time the user process is said to be in kernel mode and cannot be preempted by any user processes.

3.1.2 Process Control Block

Processes have characteristics used for identification and determining their behavior during execution. The kernel maintains data structures and provides system functions that allow the user to have access to this information. Some information is stored in the PCB (process control block). The information stored in the PCB describes the process to the operating system. This information is needed in order for the operating system to manage each process. When the operating system switches between a process utilizing the CPU to another process, it saves the current state of the executing process and its context to the PCB save area in order to restart the process the next time it is assigned to the CPU. The PCB is read and changed by various modules of the operating system. Modules concerned with the monitoring the operating system's performance, scheduling, allocating resources, and interrupt processing access and/or modify the PCB. PCB information includes:

  • current state and priority of the process

  • process, parent, and child identifiers

  • pointers to allocated resources

  • pointers to location of the process's memory

  • pointer to the process's parent and child processes

  • processor utilized by process

  • control and status registers

  • stack pointers

The information stored in the PCB can be organized as information concerned with process control such as the current state and priority of the process, pointers to parent/child PCBs, allocated resources, and memory. This also includes any scheduling- related information, process privileges, flags, messages, and signals that have to do with communication between processes (IPC, or interprocess communication). The process control information is required by the operating system in order to coordinate the concurrently active processes. Stack pointers and the content of user, control, and status registers describe information concerned with the state of the processor. When a process is running, information is placed in the registers of the CPU. Once the operating system decides to switch to another process, all the information in those registers has to be saved. When the process gains the use of the CPU again, this information can be restored. Other information has to do with process identification. This is the process id (PID), and the parent id (PPID). These identification numbers are unique for each process. They are positive, nonzero integers.



Parallel and Distributed Programming Using C++
Parallel and Distributed Programming Using C++
ISBN: 0131013769
EAN: 2147483647
Year: 2002
Pages: 133

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net