Important Terms
- Burst Time/Execution Time:
It is a time required by the process to complete execution. It is also called running time. - Arrival Time:
When a process enters in a ready state - Finish Time:
When process complete and exit from a system - Multiprogramming:
A number of programs which can be present in memory at the same time. - Jobs:
It is a type of program without any kind of user interaction. - User:
It is a kind of program having user interaction. - Process:
It is the reference that is used for both job and user. - CPU/IO burst cycle:
Characterizes process execution, which alternates between CPU and I/O activity. CPU times are usually shorter than the time of I/O.
Objective of Process Scheduling
- Maximise
- Max CPU utilization
Keep CPU as busy as possible (Fair allocation of CPU) - Max throughput
Number of processes that complete their execution per time unit
- Max CPU utilization
- Minimise
- Min turnaround time
Time taken by a process to finish execution - Min waiting time
Time a process waits in ready queue - Min response time
Time when a process produces first response
- Min turnaround time
Scheduling Queues
- Job queue − This queue keeps all the processes in the system.
- Ready queue − This queue keeps a set of all processes residing in main memory, ready and waiting to execute. A new process is always put in this queue.
- Device queues − The processes which are blocked due to unavailability of an I/O device constitute this queue.
Schedulers
Long-Term Scheduler | Short-Term Scheduler | Medium-Term Scheduler |
---|---|---|
It is a job scheduler | It is a CPU scheduler | It is a process swapping scheduler. |
Speed is lesser than short term scheduler | Speed is fastest among other two | Speed is in between both short and long term scheduler. |
It controls the degree of multiprogramming | It provides lesser control over degree of multiprogramming | It reduces the degree of multiprogramming. |
It is almost absent or minimal in time sharing system | It is also minimal in time sharing system | It is a part of Time sharing systems. |
It selects processes from pool and loads them into memory for execution | It selects those processes which are ready to execute | It can re-introduce the process into memory and execution can be continued. |
Context Switching
Scheduling Algorithms
Preemptive Vs Non-preemtive
Preemptive Scheduling | Non-preemptive Scheduling |
---|---|
A processor can be preempted to execute the different processes in the middle of any current process execution. | Once the processor starts its execution, it must finish it before executing the other. It can’t be paused in the middle. |
CPU utilization is more efficient compared to Non-Preemptive Scheduling. Waiting and response time of preemptive scheduling is less. | CPU utilization is less efficient compared to preemptive Scheduling. Waiting and response time of the non-preemptive Scheduling method is higher. |
Preemptive Scheduling is prioritized. The highest priority process is a process that is currently utilized. | When any process enters the state of running, the state of that process is never deleted from the scheduler until it finishes its job. |
In this process, the CPU is allocated to the processes for a specific time period. | In this process, CPU is allocated to the process until it terminates or switches to the waiting state. |
Examples: - Shortest Remaining Time First, Round Robin, etc. | Examples: First Come First Serve, Shortest Job First, Priority Scheduling, etc. |