
23273d6a145b872dc3cb9b2b338535b8.ppt
- Количество слайдов: 24
Chapter 2 Process Management
Objectives n After finish this chapter, you will understand: n n n the concept of a process. the process life cycle. process states and state transitions. process control blocks (PCBs)/process descriptors. how processors transition between processes via context switching. how interrupts enable hardware to communicate with software. 2
Introduction n Computers perform operations concurrently n n For example, compiling a program, sending a file to a printer, rendering a Web page, playing music and receiving e-mail Processes enable systems to perform and track simultaneous activities Processes transition between process states Operating systems perform operations on processes such as creating, destroying, suspending, resuming and waking 3
Definition of Process n A process is a program in execution. A process needs certain resources, including CPU time, memory, files, and I/O devices, to accomplish its task. n A process has its own address space consisting of: n Text region n n Data region n n Stores the code that the processor executes Stores variables and dynamically allocated memory Stack region n Stores instructions and local variables for active procedure calls 4
n The operating system is responsible for the following activities in connection with process management. n n n Process creation and deletion. process suspension and resumption. Provision of mechanisms for: n n process synchronization process communication 5
Process States: Life Cycle of a Process n n A process moves through a series of discrete process states: n Running state n The process is executing on a processor n Ready state n The process could execute on a processor if one were available n Blocked state n The process is waiting for some event to happen before it can proceed The OS maintains a ready list and a blocked list to store references to processes not running 6
Diagram of Process State Blocked 7
Process Management n Operating systems provide fundamental services to processes including: n Creating processes n Destroying processes n Suspending processes n Resuming processes n Changing a process’s priority n Dispatching a process n Blocking processes n Waking up processes n Interprocess communication (IPC) 8
State Transitions n States Transitions n n n The act of assigning a processor to the first process on the ready list is called dispatching The OS may use an interval timer to allow a process to run for a specific time interval or quantum Cooperative multitasking lets each process run to completion 9
n State Transitions n At this point, there are four possible state transitions n When a process is dispatched, it transitions from ready to running n When the quantum expires, it transitions from running to ready n When a process blocks, it transitions from running to blocked n When the event occurs, it transitions from blocked to ready 10
Process States and State Transitions Process state transitions. 11
How O. S manage process? n n Process Control Blocks (PCBs)/ Process Descriptors PCBs maintain information that the OS needs to manage the process n Typically include information such as n n n n Process identification number (PID) Process state Program counter Scheduling priority A pointer to the process’s parent process Pointers to the process’s child processes Pointers to locate the process’s data and instructions in memory 12 Pointers to allocated resources
Process Control Block 13
Process Control Blocks (PCBs)/ Process Descriptors n Process table n n n The OS maintains pointers to each process’s PCB in a process table Allows for quick access to PCBs When a process is terminated, the OS removes the process from the process table and frees all of the process’s resources 14
Process Control Blocks (PCBs)/ Process Descriptors Process table and process control blocks. 15
Process Operations n A process may spawn a new process n n The creating process is called the parent process The created process is called the child process Exactly one parent process creates a child When a parent process is destroyed, operating systems typically respond in one of two ways: n n Destroy all child processes of that parent Allow child processes to proceed independently of their parents 16
Process Operations Process creation hierarchy. 17
Suspend and Resume n Suspending a process n n Indefinitely removes it from contention for time on a processor without being destroyed A suspension may be initiated by the process being suspended or by another process A suspended process must be resumed by another process Two suspended states: n n suspendedready suspendedblocked 18
Suspend and Resume Process state transitions with suspend and resume. 19
Context Switching n Context switches- Process of CPU Switch From Process to Process n Performed by the OS to stop executing a running process and begin executing a previously ready process n Save the execution context of the running process to its PCB n Load the ready process’s execution context from its PCB n Require the processor to not perform any “useful” computation n OS must therefore minimize context 20 switching time
Context Switching Process Context switch Process. 21
CPU Switch From Process to Process 22
Process Scheduling Queues n n Job queue – set of all processes in the system. Ready queue – set of all processes residing in main memory, ready and waiting to execute. Device queues – set of processes waiting for an I/O device. Process migration between the various queues. 23
Review Questions n n n How operating system manage processes? Explain the word PCB, Process Table, Context switching Describe about Process States or Process Life Cycle. 24
23273d6a145b872dc3cb9b2b338535b8.ppt