Outline contemporary computer systems allow multiple programs to be loaded into memory and executed concurrently a system therefore consists of a collection of processes a program in execution operating system processes executing system code and user processes executing user code · Process concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server SystemS
Outline • contemporary computer systems allow multiple programs to be loaded into memory and executed concurrently • A system therefore consists of a collection of processes (a program in execution): operating system processes executing system code and user processes executing user code. • Process Concept • Process Scheduling • Operations on Processes • Interprocess Communication • Examples of IPC Systems • Communication in Client-Server Systems*
Process concept a process is an instance of a program in execution Batch systems work in terms of jobs". Many modern process concepts are still expressed in terms of jobs, (e. g job scheduling and the two terms are often used interchangeably
Process Concept • A process is an instance of a program in execution. • Batch systems work in terms of "jobs". Many modern process concepts are still expressed in terms of jobs, ( e.g. job scheduling ), and the two terms are often used interchangeably
The process Process memory is divided into four sections max stack The text section comprises the compiled program code, read in from an executable program The data section stores global and static variables allocated and initialized prior to executing main The heap is used for dynamic memory allocation, and is managed via calls to new, delete malloc, free, etc The stack is used for function parameters, local variables return addresses data Current activity including status, program counter text processor registers,…
- The Process • Process memory is divided into four sections: • The text section comprises the compiled program code, read in from an executable program. • The data section stores global and static variables, allocated and initialized prior to executing main. • The heap is used for dynamic memory allocation, and is managed via calls to new, delete, malloc, free, etc. • The stack is used for function parameters, local variables, return addresses. • Current activity including status, program counter, processor registers, …
When processes are swapped out of cpu and later restored additional information must also be stored and restored Key among them are the program counter and the value of all program registers
• When processes are swapped out of CPU and later restored, additional information must also be stored and restored. Key among them are the program counter and the value of all program registers
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 terminated ready running 10 or event completion scheduler dispatch 2I0 or event wait waitin 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-Eg page tables or segment tables memory limits Accounting information-user and kernel CPU time list of open files consumed, time limits, etc 1o 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