Program vs Process Program is passive entity stored on disk (executable file),process is active Program becomes process when a executable file loaded into memory Execution of program started via GUl mouse clicks,command line entry of its name,etc One program can be several processes Consider multiple users executing the same program
Program vs Process • Program is passive entity stored on disk (executable file), process is active • Program becomes process when a executable file loaded into memory • Execution of program started via GUI mouse clicks, command line entry of its name, etc • One program can be several processes • Consider multiple users executing the same program
Process State Processes may be in one of 5 states. New-The process is in the stage of being created. Ready-The process has all the resources available that it needs to run,but the CPU is not currently working on this process's instructions. Running-The CPU is working on this process's instructions. Waiting-The process cannot run at the moment,because it is waiting for some resource to become available or for some event to occur.For example the process may be waiting for keyboard input,disk access request,inter- process messages,a timer to go off,or a child process to finish. Terminated-The process has completed
- Process State • Processes may be in one of 5 states. • New - The process is in the stage of being created. • Ready - The process has all the resources available that it needs to run, but the CPU is not currently working on this process's instructions. • Running - The CPU is working on this process's instructions. • Waiting - The process cannot run at the moment, because it is waiting for some resource to become available or for some event to occur. For example the process may be waiting for keyboard input, disk access request, interprocess messages, a timer to go off, or a child process to finish. • Terminated - The process has completed
new admitted interrupt exit terminated ready running 1/O or event completion scheduler dispatch 1/O or event wait waiting Figure 3.2-Diagram of process state
Figure 3.2 - Diagram of process state
DEMO Task manager in Windows ·ps,top The load average reported by the "w"command indicate the average number of processes in the "Ready"state over the last 1,5,and 15 minutes,i.e.processes who have everything they need to run but cannot because the CPU is busy doing something else. Some systems may have other states besides the ones listed here
• Task manager in Windows • ps, top • The load average reported by the "w" command indicate the average number of processes in the "Ready" state over the last 1, 5, and 15 minutes, i.e. processes who have everything they need to run but cannot because the CPU is busy doing something else. • Some systems may have other states besides the ones listed here
Process Control Block For each process there is a Process Control Block,PCB process state Process State-Running,waiting,...; ·Process ID process number CPU registers and Program Counter-These need to be program counter saved and restored when swapping processes in and out of the CPU. CPU-Scheduling information-Such as priority registers information and pointers to scheduling queues. Memory-Management information-E.g.page tables or memory limits segment tables. Accounting information-user and kernel CPU time list of open files consumed,time limits,etc. I/O Status information-Devices allocated,open file tables,etc
- Process Control Block • For each process there is a Process Control Block, PCB • Process State - Running, waiting, …; • Process ID • CPU registers and Program Counter - These need to be saved and restored when swapping processes in and out of the CPU. • CPU-Scheduling information - Such as priority information and pointers to scheduling queues. • Memory-Management information - E.g. page tables or segment tables. • Accounting information - user and kernel CPU time consumed, time limits, etc. • I/O Status information - Devices allocated, open file tables, etc