280 likes | 474 Views
Outline. Process Management. Process Manager. Process manager creates the process abstraction It implements a software environment for processes to run Process manager consists of Basic algorithms and data structures to implement the process and resource abstractions Scheduling
E N D
Outline • Process Management
Process Manager • Process manager creates the process abstraction • It implements a software environment for processes to run • Process manager consists of • Basic algorithms and data structures to implement the process and resource abstractions • Scheduling • Process synchronization • A deadlock strategy • Protection strategy COP4610
Process Manager – cont. COP4610
Process Model • A process consists of the following tangible elements • A program to define the behavior of the process • The data operated on by the process and the results it produces • A set of resources • The process descriptor for the OS to keep track of the process COP4610
Processes – cont. COP4610
Process Descriptor • Process descriptor (also called process control block) • Is the data structure used by the process manager to record the status of a process while the process manager algorithms monitor and control the process COP4610
Process Descriptor – cont. • Process descriptor includes the following • Its processor registers contents at the time it was last suspended • Its processor state • The address space mapping details • Its memory state • A pointer to its stack • The resources that have been allocated to it • The resources that it needs COP4610
Process Descriptor – cont. COP4610
Process State Diagram COP4610
Process State Diagram – cont. • Process creation (new ready) • Create/find an available process descriptor entry • Assign a unique process ID • Define the address space that the process needs • Load the desired program into the address space • Initialize the data, stack, and resources available to the process • Set the process’s state to ready and add to the ready queue COP4610
Process State Diagram – cont. • Ready list – set of all processes residing in main memory, ready and waiting to execute • Ready Running • By the CPU scheduler • When the process is chosen to run next, the OS restores the register values from the process descriptor, including PC and the process starts running again COP4610
Process State Diagram – cont. • Context switch • When CPU is switched to another process, the system must save the status of the old process and load the saved status for the new process • Context switch time is overhead; the system does not do useful work while switching from application’s point of view • Context switch time is hardware dependent; it can be a significant factor in CPU scheduling algorithm design COP4610
Process State Diagram – cont. • How many context switches does it take for the • OS to switch from one user process to another? COP4610
Process State Diagram – cont. • Running Blocked • When the resources requested by the process are not available immediately, the process will be blocked, and its state will be changed from running to blocked and be removed from the ready list COP4610
Process State Diagram – cont. • Running Ready • In a time-sharing system, when a process uses its allowed time slice, it will be suspended by OS through a timer interrupt • The process will be put back to the ready list and the scheduler will choose one among the ready processes COP4610
Process State Diagram – cont. • Running Running • When the resources requested are available immediately, the process allows to continue to run. • This, however, depends on the scheduling algorithm implementation COP4610
Process State Diagram – cont. • Running Terminated • When a process finishes, the OS will release the resources allocated to the process • The process descriptor data structure will also be released • However, it may not be done immediately • In UNIX, the process descriptor is released after the parent has called “wait” system call to collect its status information • If the process’s parent exits before it does, the process becomes a zombie COP4610
Process State Diagram – cont. • Blocked Ready • When the resources requested by the process become available, the process will be marked as ready and be put back into the ready list COP4610
Process Address Space • Process address space • A set of locations used by a process to reference primary memory locations, OS services, and resources COP4610
Process Address Space – cont. COP4610
Process Address Space – cont. COP4610
Process Hierarchy COP4610
Unix Process Hierarchy COP4610
Resource Manager • Each resource type is associated with a resource manager • The resource manager is responsible for allocating resources to processes and returning released resources COP4610
Resource Manager – cont. COP4610
Resource Manager – cont. • Resource descriptor is to save the state of the resource type COP4610
Resource Manager – cont. COP4610
Resource Manager – cont. • Reusable resources • Resources that can be allocated and must be returned to the system after the process has finished using them • Such as memory • Consumable resources • Resources that can cause a process to be blocked on request but are never released by that process • Such as input data COP4610