- Circumstances of CPU scheduling
- Goals of scheduler
- Types of schedulers
- CPU scheduling is the process of selecting the next process to be allocated to the CPU whenever the CPU becomes idle because of execution of another process is on hold(waiting state) due to the unavailability of any resources like I/O.
- The main aim of CPU scheduling is to make the system efficient, fast, and fair.
- CPU scheduling is also known as process scheduling or thread scheduling.
- The component of the kernel responsible for doing CPU scheduling is known as schedulers.
- The scheduler, also known as a process scheduler can be seen as a program that divides the finite resources of processor time between different runnable processes on the system.
- It is the basis of multi tasking operating system.
- By deciding what process can run, the scheduler is responsible for best utilizing the system and giving the impression that multiple processes are simultaneously executing.
Circumstances of CPU scheduling:
There are four circumstances when a CPU scheduling is needed:
- When a process switches from the running state to waiting for the state(I/O request).
- When a process switches from the running state to the ready state( interrupt occurs).
- When a process switches from the waiting state to the ready state(Completion of I/O).
- When a process terminates.
Refer the process state diagram for details on these four transitions.
Goals of Schedulers:
- Maximize fairness:
This ensures that each process gets a fair amount of time for execution.
- Minimum latency time:
It is the amount of time taken to execute a particular process also known as turnaround time
- Maximum Throughput:
It is the total number of processes completed per unit of time
- Minimum Response time:
It is the amount of time it takes when a request was submitted until the first response is produced.
Types of schedulers:
There are three types of schedulers:
- Long Term Schedulers
- Medium Term Schedulers
- Short Term Schedulers
Long Term Schedulers:
- This scheduler is responsible for moving the job to the ready state from New state that is from the job queue on secondary memory to the ready queue on main memory.
- It is also known as Job schedulers.
- It defines the degree of multiprogramming that is having more than one job in ready state/main memory.
- It has a major impact on the performance of the system for a longer duration hence the long-term scheduler.
- There can be CPU bound or I/O bound process thus LT must be careful in picking up the jobs, that is it should pick a mix of I/O bound and CPU bound else it may lead to CPU being Idle if most of the process picked is I/O bounds
Mid Term Schedulers:
- Medium term scheduling is part of the swapping.
- If a process needs an I/O request and is moved to wait state and being in wait or block, it cannot make progress, thus it’s good to move such process from main memory to secondary memory to make room for another process (if required).
- This moving of process from main memory to secondary memory is called swapping and Mid term scheduler is responsible for this.
- Thus it reduces the degree of multiprogramming.
- MD scheduler impacts the swapping that is moving a process from main memory to secondary memory and vice versa, thus MT should be efficient for swapping a process as swapping takes a considerable amount of time.
Short Term Scheduler:
- This scheduler is responsible for moving the job from ready to running state.
- This is also known as process scheduler or CPU scheduler that is providing the processor for running.
- Short term scheduler also known as a dispatcher, executes most frequently and makes the fine-grained decision of which process to execute next.
- It is responsible for performing context switching, that is replacing the current context of the process with the new process thus the size of the context should be as small as possible for better performance of a system, and it’s responsible for the ST scheduler.
- In many OS systems, short term scheduler is just picking the jobs from the ready state while the dispatcher is responsible for moving it to the run state that is to the CPU.
ST –Context switching time
MT –swapping Time
Diag-1: Process State with Schedulers
- Process States
- Scheduling Algorithm
- Priority Inversion and its solutions
- Preemptive and Non-Preemptive scheduling
Categories: Operating system (OS)
Leave a Reply