Académique Documents
Professionnel Documents
Culture Documents
Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems
4.1
Process Concept
Process a program in execution.
variables,return address) data section(global variables) Program is passive entity, whereas a process is an active entity. If multiple users invoke same copy of the internet explorer,these will be separate processes, despite belonging to the same passive entity.
Operating System Concepts
4.2
Process State
As a process executes, it changes state
New: The process is being created. Running: Instructions are being executed.
At one moment of time, only one process can be in running state. Waiting: The process is waiting for some event to occur. Ready: The process is waiting to be assigned to a process. Terminated: The process has finished execution. Many processes can be in the ready and waiting state.
Operating System Concepts
4.3
4.4
Process Control Block(PCB). PCB contains: Process state (running,ready,waiting) Program Counter CPU registers (accumulator, general-purpose registers) CPU scheduling information (priority and other info) Memory-management information (base and limit registers, page table or segment table) Accounting information (CPU time used, time limits, process numbers etc.) I/O status information (list of I/O devices allocated to the process, list of open files,etc..)
Operating System Concepts
4.5
4.6
4.7
Process Scheduling
The objective of multiprogramming is to have
some process running all the time, i.e to maximize CPU utilization. The objective of time-sharing system is to switch among processes so frequently that each user is given the impression that he is the sole user of the system. In uniprocessor system, only one process can be in the running state, so other processes must wait until they are scheduled.
4.8
The moment a process enters the system,it is placed in the job queue. Ready queue set of all processes residing in main memory, ready and waiting to execute. This queue is generally maintained as a link-list. Device queues set of processes waiting for an I/O device. Each device has its own separate device queue.
4.9
4.10
4.11
Schedulers
Scheduler Though there are multiple processes
ready to be run, the selection process is required to select the process. This selection process is done by the scheduler. Long-term scheduler (or job scheduler) selects which processes should be brought into the ready queue from the hard disk to the main memory. Short-term scheduler (or CPU scheduler) selects which process should be executed next and allocates CPU to that process. It selects the process from main memory.
4.12
frequently, coz the scheduler has to switch between processes many times. Though the short term scheduler is executed more frequently, it should be very fast, so that minimal time is wasted for switching.
4.13
afford to take more time to select the processes from hard disk. Long term scheduler is required only when any one the processes terminates and leaves the system. Long-term scheduler controls the degree of multiprogramming(the number of process in main memory). If the degree of multi-programming is stable then average rate of process creation should be equal to average rate of process departure. I/O bound process If a process takes more time doing I/O than CPU execution, it is called I/O bound process. CPU bound process - If a process takes more time in CPU execution than I/O, it is called CPU bound process. Long term scheduler must select a good mix of CPU and I/O bound processes.
4.14
selected a good mix of CPU and I/O bound processes, more time is wasted in switching than doing actual work. Medium Term Scheduler removes processes from memory and thus reduces the degree of multiprogramming. The process can be reintroduced into memory and execution can be continued from where it was left. This scheme is called swapping. The process is swapped out, and is later swapped in, by the medium term scheduler. Swapping is necessary to improve the process mix in main memory.
4.15
4.16
Context Switch
When CPU switches to another process, the system must
save the state of the old process and load the saved state for the new process. This task is known as context switch. Context-switch time is overhead; the system does no useful work while switching. Time dependent on hardware support and varies from machine to machine.
4.17
Process Creation
A process may create several new processes, the creating
process is called Parent process, while the created process is called a child process, forming a tree of processes.
Resource sharing Parent and children share all resources. Children share subset of parents resources. Parent and child share no resources. In addition to resources, initialization data is also passed
Process Termination
Process executes last statement and asks the operating
system to delete it by calling exit system call. Output data from child to parent (via wait). Process resources are deallocated by operating system. Parent may terminate execution of children processes using abort system call. Parent terminate the child process if: 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.This is called Cascading termination.
Operating System Concepts
4.19