0% found this document useful (0 votes)
6 views19 pages

CPU scheduling-Intro&FCSC

CPU scheduling is essential for determining which process uses the CPU while others wait, aiming to maximize CPU utilization and minimize idle time. Effective scheduling algorithms enhance resource utilization, ensure fairness, and reduce turnaround, waiting, and response times. There are two main types of scheduling: preemptive and non-preemptive, with various algorithms like First Come First Serve (FCFS) having distinct advantages and disadvantages.

Uploaded by

Armaan Ahuja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views19 pages

CPU scheduling-Intro&FCSC

CPU scheduling is essential for determining which process uses the CPU while others wait, aiming to maximize CPU utilization and minimize idle time. Effective scheduling algorithms enhance resource utilization, ensure fairness, and reduce turnaround, waiting, and response times. There are two main types of scheduling: preemptive and non-preemptive, with various algorithms like First Come First Serve (FCFS) having distinct advantages and disadvantages.

Uploaded by

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

What is the need for CPU scheduling algorithm?

• CPU scheduling is the process of deciding which process will own the
CPU to use while another process is suspended. The main function of
the CPU scheduling is to ensure that whenever the CPU remains idle,
the OS has at least selected one of the processes available in the
ready-to-use line.
• In Multiprogramming, if the long-term scheduler selects multiple I / O
binding processes then most of the time, the CPU remains an idle. The
function of an effective program is to improve resource utilization.
• If most operating systems change their status from performance to
waiting then there may always be a chance of failure in the system. So
in order to minimize this excess, the OS needs to schedule tasks in
order to make full use of the CPU and avoid the possibility of deadlock.
Objectives of Process Scheduling Algorithm:

• 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.
Criteria to use CPU Scheduling
Different CPU Scheduling algorithms have different structures and
the choice of a particular algorithm depends on a variety of factors.
Many conditions have been raised to compare CPU scheduling
algorithms.
• The criteria include the following:
• CPU utilization: The main purpose of any CPU algorithm is to keep
the CPU as busy as possible. Theoretically, CPU usage can range
from 0 to 100 but in a real-time system, it varies from 40 to 90
percent depending on the system load.
• Throughput: The average CPU performance is the number of
processes performed and completed during each unit. This is called
throughput. The output may vary depending on the length or
duration of the processes.
Continued…………………………………
…………
• Turn round Time: For a particular process, the important conditions are
how long it takes to perform that process. The time elapsed from the time of
process delivery to the time of completion is known as the conversion time.
Conversion time is the amount of time spent waiting for memory access,
waiting in line, using CPU, and waiting for I / O.
• Waiting Time: The Scheduling algorithm does not affect the time required
to complete the process once it has started performing. It only affects the
waiting time of the process i.e. the time spent in the waiting process in the
ready queue.
• Response Time: In a collaborative system, turn around time is not the best
option. The process may produce something early and continue to
computing the new results while the previous results are released to the
user. Therefore another method is the time taken in the submission of the
application process until the first response is issued. This measure is called
response time.
Types of CPU Scheduling Algorithms

There are mainly two types of scheduling methods:


• Preemptive Scheduling: Preemptive scheduling is used
when a process switches from running state to ready
state or from the waiting state to the ready state.
• Non-Preemptive Scheduling: Non-Preemptive scheduling
is used when a process terminates , or when a process
switches from running state to waiting state.
First Come First Serve:

FCFS considered to be the simplest of all operating system


scheduling algorithms. First come first serve scheduling algorithm
states that the process that requests the CPU first is allocated the
CPU first and is implemented by using FIFO queue.
• Characteristics of 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 much efficient in performance, and the
wait time is quite high.
Continued…………………………………
………………….
Advantages of FCFS:
• Easy to implement
• First come, first serve method
Disadvantages of FCFS:
• FCFS suffers from Convoy effect.
• The average waiting time is much higher than the other
algorithms.
• FCFS is very simple and easy to implement and hence
not much efficient.
Example:
Consider the following table of
arrival time and burst time for five processes P1, P2, P3,
P4 and P5.
Processes Arrival Time Burst Time
P1 0 4
P2 1 3
P3 2 1
P4 3 2
P5 4 5
CONTINUED………………………………
……………….
Continued…………………………………
…………………
Continued…………………………………
…………………
Continued…………………………………
……………….
Continued…………………………………
……………….
Step 5: At time = 4,
Continued…………………………………
……………………
Continued…………………………………
……………….
Continued…………………………………
………………..
Continued…………………………………
………………
Continued…………………………………
…………………..
Gantt chart

Waiting Time = Start time – Arrival time


P1 = 0 – 0 = 0
P2 = 4 – 1 = 3
P3 = 7 – 2 = 5
P4 = 8 – 3 = 5
P5 = 10 – 4 = 6
Average waiting time = (0 + 3 + 5 + 5+ 6 )/ 5 = 19 / 5 = 3.8

You might also like