0% found this document useful (0 votes)
16 views

Process Scheduling & Algorithms

Uploaded by

Srinivasa Rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Process Scheduling & Algorithms

Uploaded by

Srinivasa Rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Process scheduling

Process scheduling is an essential part of a Multiprogramming operating system. Such operating systems
allow more than one process to be loaded into the executable memory at a time and the loaded process
shares the CPU using time multiplexing.

Process scheduling is the activity of the process manager that handles the removal of the running
process from the CPU and the selection of another process based on a particular strategy.

Categories of Scheduling:

Scheduling falls into one of two categories:

 Non-preemptive: In this case, a process’s resource cannot be taken before the process has
finished running.
 Preemptive: In this case, the OS assigns resources to a process for a predetermined period.
The process switches from running state to ready state or from waiting for state to ready state
during resource allocation.

Types of Process Schedulers:

There are three types of process schedulers:

1. Long Term or Job Scheduler OR Job Scheduler: It selects new processes from the
pool (or the secondary memory) and then maintains them in the primary memory’s ready
queue.

It controls the Degree of Multi-programming, i.e., the number of processes present in a


ready state at any point in time. It is important that the long-term scheduler make a
careful selection of both I/O bound & CPU-bound processes. I/O-bound tasks are
which use much of their time in input and output operations while CPU-bound processes
are which spend their time on the CPU. The job scheduler increases efficiency by
maintaining a balance between the two.

2. Short-Term Scheduler OR CPU Scheduler: It is responsible for selecting one process


from the ready state (primary memory) for scheduling it on the running state (primary
memory). It determines which work will be dispatched for execution.

Here is when all the scheduling algorithms are used. The CPU scheduler is responsible
for ensuring no starvation due to high burst time processes.

3. Medium-Term Scheduler OR Swap Scheduler: It is responsible for suspending and


resuming the process. It mainly does swapping (moving processes from main memory to
disk and vice versa).
Process Schedulers
Basic Terminologies which are to be used in the CPU Scheduling Algorithms

Process ID : The Process ID acts like the name of the process.

Arrival Time (AT) : It is the point of time at which the process arrives in the ready queue & it
is eligible for scheduling.

Burst Time (BT) : It is the amount/duration of CPU time that is required by a process for its
overall execution.

Completion Time (CT): It is the point of time when a process finishes its execution & is no
longer being processed by the CPU. It is the summation of the arrival time, waiting time and
burst time.

Turnaround Time (TAT): It is about how much time a process is being stayed in the system. It
means when it got completed its job & when it arrived for processing. So, TAT is the time
Difference between completion time and arrival time.

TAT = CT - AT (OR) TAT = WT + BT

Waiting Time (WT) : It is the process’s duration in the ready queue before it begins executing.
WT means how much was the useful time(BT) and how much time it was spend there in the
system (TAT). So, it is the time difference between turnaround time and burst time.

WT = TAT – BT

Response time (RT) : It is the amount of time it takes for the CPU to respond to a request made
by a process. So, it is the duration between the arrival of a process and the first time it got the
CPU for running.

RT = ST – AT
First Come First Serve (FCFS)

As the name suggests, the First Come First Serve (FCFS) algorithm assigns the CPU to
the process that arrives first in the ready queue. This means that the process that requests
the CPU for its execution first will get the CPU allocated first. This is managed through
the FIFO queue. The lesser the arrival time of processes in the ready queue, the sooner
the process gets the CPU.

Advantages of FCFS algorithm

 It is the simplest form of a scheduling algorithm.


 Its implementation is easy and it is first-come, first-served.

Disadvantages of FCFS algorithm

 Due to the non-preemptive nature of the algorithm, short processes at the end of the
queue have to wait for long processes that are present at the front of the queue to finish.
 There is a high average waiting time that causes a starvation problem, it means when a
process waits for an indefinite time to get the resource it requires.

Average TAT: 29/5 = 5.8

Average WT: 14/5 = 2.8

Average RT: 14/5 = 2.8

N.B: In case of non-preemptive CPU scheduling algorithm WT & RT always remains same.
Shortest Job First (SJF)

The Shortest Job is heavily dependent on the Burst Times. Every CPU Scheduling Algorithm is
basically dependent on the Arrival Times. Here, in this Shortest Job First CPU Scheduling
Algorithm, the CPU allots its resources to the process which is in ready queue and the process
which has least Burst Time.

If we face a condition where two processes are present in the Ready Queue and their Burst Times
are same, we can choose any process for execution. In actual Operating Systems, if we face the
same problem then sequential allocation of resources takes place.

SJF has the least average waiting time. This is because all the heavy processes are executed at
the last. So, because of this reason all the very small, small processes are executed first and
prevent starvation of small processes.

Shortest Job can be executed in non pre emptive way (Shortest Job First i.e. SJF) and also in
Pre emptive way (Shortest Reaming Time First i.e. SRTF).

Advantages of SJF

 Shorter waiting time compared to First In First Out Algorithm.


 SJF is used because it has the least average waiting time than the other CPU Scheduling
Algorithms.
 Helpful for batch-type processing where runtimes are known in advance.

Disadvantages of SJF

 SJF may cause starvation if shorter processes keep coming. This problem is solved by
aging.
 Cause extremely long turnaround times or starvation.
 Can lead to starvation of processes that has larger burst times.
Shortest Remaining Time First (SRTF)

It is the preemptive version of Shortest Job First (SJF) scheduling is known as Shortest
Remaining Time First (SRTF). With the help of the SRTF algorithm, the process having the
smallest amount of time remaining until completion is selected first to execute.

So basically in SRTF, the processes are scheduled according to the shortest remaining time.

However, the SRTF algorithm involves more overheads than the Shortest job first
(SJF)scheduling, because in SRTF OS is required frequently in order to monitor the CPU time of
the jobs in the READY queue and to perform context switching.

In the SRTF scheduling algorithm, the execution of any process can be stopped after a certain
amount of time. On arrival of every process, the short-term scheduler schedules those processes
from the list of available processes & running processes that have the least remaining burst time.

Advantages of SRTF:
 SRTF algorithm makes the processing of the jobs faster than SJN algorithm, if its overhead
charges are not counted.
 Allows for easier management of library updates or replacements without recompiling the
program.
 Enables efficient memory usage, as libraries can be shared among multiple instances of the
program.
Disadvantages of SRTF:
 The context switching is done a lot more times in SRTF than in SJN. As a result it consumes
CPU’s valuable time for selecting the minimum burst time process among all processes from
the ready queue. This adds up to its processing time and diminishes it’s advantage of fast
processing.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy