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.
- In this the process running can be forced to yield CPU in between of their execution.
- Timer and other interrupts may be reason for half way yield of CPU.
- In this scheduling method the tasks are mostly assigned with their priorities, and higher priority task are made to execute by yielding CPU from lower priority task.
- It is mainly used when a process switches either from running state to ready state or from waiting state to ready state.
- The resources are mainly allocated to the process fro a limited amount if time and then taken away and put in ready queue. It stays in ready queue until it get its chance to execute next.
- Some Algorithms that are based on preemptive scheduling are Round Robin Scheduling (RR), Shortest Remaining Time First (SRTF), Priority (preemptive version) Scheduling, etc.
- In this the process runs until it voluntarily yields CPU in below scenarios:
- Process blocks on an event(I/O or synchronization)
- Process yields
- Process terminates
- Some Algorithms based on non-preemptive scheduling are: Shortest Job First (SJF basically non-preemptive) Scheduling and Priority (non- preemptive version) Scheduling, etc.
Advantages and Disadvantages:
Advantages of Preemptive Scheduling:
- It adds more responsiveness to the system as one process cannot monopolize the CPU.
- The OS makes sure that the CPU usage is the same by all running processes.
- This method improvises the average response time.
- Preemptive Scheduling is beneficial when used for the multi-programming environment.
Disadvantages of Preemptive Scheduling:
- There is an overhead of context switching at each preemption.
- Need limited computational resources for scheduling.
- The process which has low priority needs to wait for a longer time if some high priority processes arrive continuously.
Advantages of Non-Preemptive Scheduling:
- It offers low scheduling and context switching overhead.
- Less computational resources need for Scheduling.
- Tends to offer high throughput
Disadvantages for Non-Preemptive Scheduling:
- The system becomes less responsiveness, not suitable for real time system
- It can lead to starvation especially for those real-time tasks.
- Poor response time for processes
- CPU Scheduling.
- Types of schedulers.
- Scheduling Algorithm
- Priority Inversion and its solutions
- Process States
Categories: Operating system (OS)
Leave a Reply