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

Process Scheduling

Uploaded by

mishujaat81
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Process Scheduling

Uploaded by

mishujaat81
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Process Scheduling

Process Scheduling

• The 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 on the basis of a particular strategy.
• Process scheduling is an essential part of a Multiprogramming operating
systems.
• 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.
Categories of Scheduling

1. Non-preemptive: Here the resource can’t be taken from a process until


the process completes execution. The switching of resources occurs when
the running process terminates and moves to a waiting state.
2. Preemptive: Here the OS allocates the resources to a process for a fixed
amount of time. During resource allocation, the process switches from
running state to ready state or from waiting state to ready state. This
switching occurs as the CPU may give priority to other processes and
replace the process with higher priority with the running process.
CPU–I/O Burst Cycle
• Process execution consists of a cycle
of CPU execution and I/O wait
Dispatcher
• Dispatcher module gives control of the CPU to the process selected by the
scheduler; this involves:
• switching context
• switching to user mode
• jumping to the proper location in the user program to restart that
program
• Dispatch latency – time it takes for the dispatcher to stop one process and
start another running
Objectives of Process Scheduling

• Utilization of CPU at maximum level. Keep CPU as busy as possible.


• Allocation of CPU should be fair.
• Throughput should be Maximum. i.e. Number of processes that complete their
execution per time unit should be maximized.
• Minimum turnaround time, i.e. time taken by a process to finish execution should be
the least.
• There should be a minimum waiting time and the process should not starve in the
ready queue.
• Minimum response time. It means that the time when a process produces the first
response should be as less as possible.
Types of Schedulers

• Schedulers are special system software which handle process scheduling


in various ways. Their main task is to select the jobs to be submitted into
the system and to decide which process to run. Schedulers are of three
types −
• Long-Term Scheduler
• Short-Term Scheduler
• Medium-Term Scheduler
Long Term Scheduler

• It is also called a job scheduler.


• A long-term scheduler determines which programs are admitted to the system for
processing.
• It selects processes from the queue and loads them into memory for execution. Process
loads into the memory for CPU scheduling.
• The primary objective of the job scheduler is to provide a balanced mix of jobs, such as
I/O bound and processor bound.
• It also controls the degree of multiprogramming. If the degree of multiprogramming is
stable, then the average rate of process creation must be equal to the average departure
rate of processes leaving the system.
Short Term Scheduler

• It is also called as CPU scheduler.


• Its main objective is to increase system performance in accordance with the
chosen set of criteria.
• It is the change of ready state to running state of the process.
• CPU scheduler selects a process among the processes that are ready to execute
and allocates CPU to one of them.
• Short-term schedulers, also known as dispatchers, make the decision of which
process to execute next.
• Short-term schedulers are faster than long-term schedulers.
Medium Term Scheduler

• Medium-term scheduling is a part of swapping. It removes the processes


from the memory.
• It reduces the degree of multiprogramming.
• The medium-term scheduler is in-charge of handling the swapped
out-processes.
Scheduling Criteria
• CPU utilization – keep the CPU as busy as possible
• Throughput – Throughput of processes that complete their execution per time
unit
• Turnaround time – amount of time to execute a particular process
• Waiting time – amount of time a process has been waiting in the ready queue
• Response time – amount of time it takes from when a request was submitted
until the first response is produced, not output (for time-sharing environment)
FCFS

• FCFS supports non-preemptive and preemptive CPU scheduling


algorithms.
• Tasks are always executed on a First-come, First-serve concept.
• FCFS is easy to implement and use.
• This algorithm is not very efficient in performance, and the wait time is
quite high.
First-Come First-Served (FCFS) Scheduling
Process Burst Time
P1 24
P2 3
P3 3
• Suppose that the processes arrive in the order: P1 , P2 , P3
The Gantt Chart for the schedule is:

P1 P2 P3

0 24 27 30
• Waiting time for P1 = 0; P2 = 24; P3 = 27
• Average waiting time: (0 + 24 + 27)/3 = 17
FCFS Scheduling (Cont.)
Suppose that the processes arrive in the order:
P2 , P3 , P1
• The Gantt chart for the schedule is:

P2 P3 P1

0 3 6 30

• Waiting time for P1 = 6; P2 = 0; P3 = 3


• Average waiting time: (6 + 0 + 3)/3 = 3
• Much better than previous case

You might also like