Unit 1 part A PROCESS Process Concept Process
- Slides: 31
Unit 1 -part A PROCESS • • • Process Concept Process states Process Scheduling CONTEXT switch Process description Operations on Processes Execution of OS Interprocess Communication in Client-Server Systems
What is Process ? ? ? • A process is a program during execution. – Program is a static file – Process is execution program. • A process is the basic unit of execution in an operating system – Each process has a number, its process identifier (pid). • Process requires following components : - object program - Data - Resources - Status
Difference between PROGRAM • It is static entity made up of program statements PROCESS • Process is dynamic entity that is program in execution • Program defines a task or job for OS • 2 or more processes could be executing the same program, each using their own data. • It is Considered to be Passive entity. • It is active entity. • Programs do not compete for resources like CPU, Memory • Process do compete for resources like CPU, Memory
Process State As a process executes, it changes state new: The process is being created. running: Instructions are being executed. waiting: The process is waiting for some event to occur. ready: The process is waiting to be assigned to a processor. terminated: The process has finished execution.
B) Suspended Process • Suspended process is not immediately available for execution. • The process may be or may not be waiting for process. • For preventing the execution, process is suspended by OS , Parent process. , process itself and an agent. • Process may not be removed from the suspended state until agent orders the removal.
Suspended Process
Reasons for Process Suspension
PCB(Process control Block) Identifier Process state Priority Program Counter Memory Pointer Register CPU Scheduling Info Memory Mgmt Info Accounting Info I/O Status Information
Process Scheduling Need of Scheduling : -> • The objective of Multiprogramming is to have some process running at all times, to maximize CPU utilization. • The objective of Time sharing is to switch the CPU among Process so frequently that users can interact with each program while it is running. • To meet this objective , the process scheduler selects available process for program execution on CPU.
Process Scheduling • 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 migrates between the various queues.
Ready Queue And I/O Device Queues
Representation of Process Scheduling
SCHEDULERS Definition : • A Process Migrates among various scheduling Queue throughout its lifetime. • The OS must select, for scheduling purpose, the process from these Queues in fashion. The selection Process is carried out by scheduler.
SCHEDULERS • Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue. • Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU.
SCHEDULERS • Medium – Term Scheduler : The key idea is to remove process from memory & thus reduce the degree of multiprogramming. • And later when required can be swapped into memory back. • Swapping is conducted by Medium term scheduler
SCHEDULERS Queuing – diagram representation of process scheduling
SCHEDULERS • Processes can be described as either: – I/O-bound process – spends more time doing I/O than computations. – Ready Queue will be almost empty – CPU-bound process – spends more time doing computations; – Waiting Queue will be empty.
CONTEXT SWITCH What is a process context? The context of a process includes the values of CPU registers, the process state, the program counter, and other memory/file management information. What is a context switch? After the CPU scheduler selects a process (from the ready queue) and before allocates CPU to it, the CPU scheduler must 1. 2. 3. 4. save the context of the currently running process, put it into a queue, load the context of the selected process, and let it run.
CONTEXT SWITCH CO
Process Description OS schedules & dispatches processes for execution by the processor, allocated resources to processes & responses to request by user processes for basic services.
Process Description • If OS is to manage process & resources it must have Information about the current status of each process and resource • Tables are constructed for each entity the operating system manages. • OS maintains 4 different tables : 1. Memory table 2. I/O table 3. File table 4. Process table
General Structure of OS control table
1) Memory table : • Allocation of main memory to processes • Allocation of secondary memory to processes • Protection attributes for access to shared memory regions • Information needed to manage virtual memory I/O Tables : • I/O device is available or assigned to particular process • Status of I/O operation • Location in main memory being used as the source or destination of the I/O transfer
3) File TABLE : • Existence of files • Location on secondary memory • Current Status • Attributes • Sometimes this information is maintained by a file management system. 4) Process Table OS uses Process table to manage process
Process Control • Many Processor supports atleast 2 modes of execution: • 1) User Mode : less Privileged mode. Linux uses 1 psw for user mode 2) Kernel mode : More Privileged mode. LINUX uses 0 psw for kernel mode
Process Operation There are three commonly seen operations: 1. Process Creation: Create a new process. The newly created is the child of the original. Use fork() or in Unix to create new processes. 2. Process Termination: Terminate the execution of a process. Under Unix, use exit(). 3. Process Join: Wait for the completion of a child process. Under Unix use wait(). v fork(), vfork(), exit() and wait() are system calls. v Use “ps –aux” to see all running processes
Process Creation • Parent process create children processes, which, in turn create other processes, forming a tree of processes. • Resource sharing – Parent and children share all resources. – Children share subset of parent’s resources. – Parent and child share no resources. • Execution – Parent and children execute concurrently. – Parent waits until children terminate.
Process Creation • Address space – Child process is a duplicate of parent process – Child has a new program loaded into it. • UNIX examples: – fork system call creates new process – exec system call used after a fork to replace the process’ memory space with a new program.
Process Creation A tree of Process on Typical UNIX system
Example of fork() int main() { pid_t pid; /* fork another process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, ”Fork Failed”); exit(-1); } else if (pid == 0) { /* child process */ execlp(”/bin/ls”, ”ls”, NULL); } else { /* parent process */ /* wait for the child to complete */ } wait(NULL); printf (”Child Complete”); exit(0); }
Process Termination • Process executes last statement and asks the OS to delete it (exit). – Output data from child to parent (via wait). – Process’ resources are deallocated by OS. • Parent may terminate execution of children processes (abort). some reasons for doing so are: – Child has exceeded allocated resources. – Task assigned to child is no longer required. – Parent is exiting &Operating system does not allow child to continue if its parent terminates.
- Unit 10, unit 10 review tests, unit 10 general test
- Part whole model subtraction
- Part to part ratio definition
- Part part whole
- Technical description examples
- It is the heart of the entire beverage operation
- The part of a shadow surrounding the darkest part
- Two way anova minitab 17
- Idealized self example
- Contoh marketing concept
- Unit process and unit operation
- Unit operation and unit process
- Ap psychology unit 7
- Rotational inertia and torque
- Properties of a kite
- Expressions, equations, and inequalities unit test part 1
- Expressions, equations, and inequalities unit test part 1
- External part of a system unit
- Ap psych unit 7 part 2
- Linear equations unit test
- Gse algebra 1 unit 1 test
- Unit 6 part 2
- Unit 7 progress check: mcq part c
- Intro to quadratics
- Unit 6 part 1
- Concept of intensive care unit
- Unit load concept in material handling
- Unit of measure concept
- Product disassembly
- Ppap vorlagestufen übersicht
- Concept map for disease process
- Discuss in detail the concept and process of hydrosere'