Advanced operating Systems sem2
Advanced operating Systems sem2
Scheduling
Presented by –
Sourav Sasmal
Presented by –
09-05-2024 Sourav Sasmal
2
What is Preemptive Scheduling?
Preemptive scheduling is a method that may be used when a process switches from a
running state to a ready state or from a waiting state to a ready state. The resources are
assigned to the process for a particular time and then removed. If the resources still have the
remaining CPU burst time, the process is placed back in the ready queue. The process
remains in the ready queue until it is given a chance to execute again.
When a high-priority process comes in the ready queue, it doesn't have to wait for the
running process to finish its burst time. However, the running process is interrupted in the
middle of its execution and placed in the ready queue until the high-priority process uses the
resources. As a result, each process gets some CPU time in the ready queue. It improves the
overhead of switching a process from running to ready state and vice versa, increasing
preemptive scheduling flexibility. It may or may not include SJF and Priority scheduling.
Algorithms based on preemptive scheduling are Round Robin (RR), Shortest Remaining Time
First (SRTF), Priority (preemptive version), etc.
Presented by –
Sourav
3 5/9/2024
Advantages and disadvantages of
Preemptive Scheduling
Advantages : -
1) Because a process may not monopolize the processor, it is a more reliable method.
2) Each occurrence prevents the completion of ongoing tasks.
3) The average response time is improved.
4) Utilizing this method in a multi-programming environment is more advantageous.
5) The operating system makes sure that every process using the CPU is using the
same amount of CPU time.
Disadvantages : -
Presented by –
4 5/9/2024 Sourav
Algorithms based on preemptive scheduling
Priority (preemptive
version)
Presented by –
5 5/9/2024 Sourav
Round Robin Scheduling
Round Robin is a CPU scheduling algorithm where each process is cyclically assigned a fixed
time slot. It is the preemptive version of the First come First Serve CPU Scheduling algorithm.
Round Robin CPU Algorithm generally focuses on Time Sharing technique.
The period of time for which a process or job is allowed to run in a pre-emptive method is called time
quantum.
Each process or job present in the ready queue is assigned the CPU for that time quantum, if the
execution of the process is completed during that time then the process will end else the process will go
back to the waiting table and wait for its next turn to complete the execution.
Characteristics of Round
Robin :-
It is simple, easy to implement, and starvation-free as all processes get a fair share of CPU.
One of the most commonly used techniques in CPU scheduling is a core.
It is preemptive as processes are assigned CPU only for a fixed slice of time at most.
The disadvantage of it is more overhead of context switching.
Presented by –
6 5/9/2024 Sourav
Advantages and disadvantages of
Round Robin Scheduling
Advantages : -
1) There is fairness since every process gets an equal share of the CPU.
2) The newly created process is added to the end of the ready queue.
3) A round-robin scheduler generally employs time-sharing, giving each job a time slot or quantum.
4) While performing a round-robin scheduling, a particular time quantum is allotted to different jobs.
5) Each process get a chance to reschedule after a particular quantum time in this scheduling.
Disadvantages : -
Presented by –
Sourav
7 5/9/2024
Shortest Remaining Time First (Preemptive SJF)
In the Shortest Remaining Time First (SRTF) scheduling algorithm, the process with the smallest
amount of time remaining until completion is selected to execute. Since the currently executing
process is the one with the shortest amount of time remaining by definition, and since that time
should only reduce as execution progresses, processes will always run until they complete or a
new process is added that requires a smaller amount of time.
Advantages:-
1. Short processes are handled very quickly.
2. The system also requires very little overhead since it only makes a decision when a process
completes or a new process is added.
3. When a new process is added the algorithm only needs to compare the currently executing
process with the new process, ignoring all other processes currently waiting to execute.
Disadvantages:-
1. Like shortest job first, it has the potential for process starvation.
2. Long processes may be held off indefinitely if short processes are continually added.
Presented by –
8 5/9/2024
Preemptive Priority Scheduling
In Preemptive Priority Scheduling, at the time of arrival of a process in the ready queue, its
Priority is compared with the priority of the other processes present in the ready queue as
well as with the one which is being executed by the CPU at that point of time. The One with
the highest priority among all the available processes will be given the CPU next.
The difference between preemptive priority scheduling and non preemptive priority
scheduling is that, in the preemptive priority scheduling, the job which is being executed can
be stopped at the arrival of a higher priority job.
Once all the jobs get available in the ready queue, the algorithm will behave as non-
preemptive priority scheduling, which means the job scheduled will run till the completion and
no preemption will be done.
Presented by –
9 5/9/2024 Sourav Sasmal
References
Presented by –
10 5/9/2024 Sourav
Thanks!
Presented by –
11 5/9/2024 Sourav Sasmal