University of Science & Technology
Chittagong
Course title: Operating Systems
Course code: CSE 327
Department of Computer Science & Engineering
(CSE)
1
Submitted by :
Piku Das (17010110)
Mizanur Rahman (17010108)
Israt Liza (17010111)
Eftykher Mahmud( 17010112)
Sushmita Dey (17010113)
Batch No : 29
Submitted to :
Fatema Tuj Zohra
(Lecturer of CSE
Department)
|
|
Presentation on
CPU Scheduling
2
Why CPU scheduling ?
One of the key goal of an operating system is to
utilize the the CPU as much as possible.
There is a situation for underutilization of CPU
because most of the component of a computer is
not as fast as the microprocessor.
To overcome the problem of underutilization of
CPU and main memory, the multiprogramming
was introduced. The objective of
multiprogramming is to have some process
running all the time. 3
Why CPU scheduling ? (cont… .)
So to implement the concept of multiprogramming we
need to design scheduling algorithms.
Whenever the CPU becomes idle , the OS must choose
one of the process in the ready queue to be executed .
The selection process is carried out by a short term
scheduler or CPU scheduler .
4
5
Preemptive Vs Non-Preemptive
Preemptive Non-Preemptive
1. Allocation For Resource
to process for Limited Time.
1. Process holds the resource till
Terminated or Switch to Waiting
State.
2. Process Can be
Interrupted in between
2. Process Can’t be Interrupted
until it terminated or switching
waiting state
3. High CPU Utilization 3. Low CPU Utilization
4. In Preemptive
Scheduling, a running
process may be replaced by
a higher priority process at
any time
4. In Non- Preemptive Scheduling,
Once the CPU has been allocated to
a process ,the process keeps the
CPU it releases the CPU either by
terminated by switching the
6
Preemptive Non-Preemptive
5. Preemptive Scheduling is
Flexible
5. Preemptive Scheduling is
Rigid
6. Preemptive Scheduling is
more Complex
6. Non-Preemptive
Scheduling is Simple but it is
less efficient
7. Preemptive Scheduling is
not attractive
7. Non-Preemptive
Scheduling is more attractive
because of its simplicity
8. Preemptive Scheduling is
cost associative
8. Non-Preemptive
Scheduling is not cost
associative
Preemptive Vs Non-Preemptive
7
9.Used in time sharing
System
9.Not suitible for time sharing
System.
10.Switching Overhead 10.Not Switching Overhead
11.SJF (Shortest Job First )
Scheduling,
Round Robin Scheduling
11. FCFS(First come First
Serve)
Preemptive Vs Non-Preemptive
8
CPU Scheduling Criteria
Scheduling Criteria:
 There are several different criteria to consider when
trying to select the "best" scheduling algorithm for a
particular situation and environment, including:
 CPU utilization - Ideally the CPU would be busy 100% of
the time, so as to waste 0 CPU cycles. On a real system CPU
usage should range from 40% ( lightly loaded ) to 90% (
heavily loaded. )
 Number of processes completed per unit time. May range
from 10 / second to 1 / hour depending on the specific
processes.
9
 Turnaround time - Time required for a particular process
to complete, from submission time to completion.
( Wall clock time. )
 Waiting time - How much time processes spend in the
ready queue waiting their turn to get on the CPU. ( Load
average - The average number of processes sitting in the
ready queue waiting their turn to get into the CPU.
 Reported in 1-minute, 5-minute, and 15-minute averages
by "uptime" and "who". ) Response time - The time taken in
an interactive program from the issuance of a command to
the commence of a response to that command.
CPU Scheduling Criteria
10
In general one wants to optimize the average value of a
criteria ( Maximize CPU utilization and throughput, and
minimize all the others. ) However some times one wants to do
something different, such as to minimize the maximum
response time.
 Sometimes it is most desirable to minimize the variance of a
criteria than the actual value. I.e. users are more accepting of a
consistent predictable system than an inconsistent one, even if
it is a little bit slower.
CPU Scheduling Criteria
What is FCFS?
 FCFS or First come first serve is an
operating system process Scheduling
algorithm that automatically executes queued
requests and processes by order of their
arrival.
5
i. Jobs are executed on first come, first serve
basis.
ii. It is an non-preemptive scheduling
algorithm.
iii.It’s implementation is based on FIFO queue.
iv.OS runs the process at head of the queue.
FCFS Basic Concepts
12
Two kinds of non-preemptive FCFS
 With priority scheme.
 No priority scheme.
Advantages
13
i. Simple Algorithm.
ii. It is simple to understand and code.
iii. Suitable for batch system.
i. Because of non-preemptive algorithm the waiting time
can be large if short request behind the long process.
ii. Not suitable for sharing system.
iii. Because of long average waiting time the performance
is poor.
Disadvantages
FCFS CPU Scheduling Algorithm
Without Arrival Time
14
Process:
The processes arrive in the order P1, P2, P3 and are served
as per the FCFS algorithm. The Gantt chart is as shown:
P1 P2 P3
0 25 29 32
Fig: Gantt Chart
16
Process Burst Time Waiting
Time
Completion
Time
Turn Around
Time
P1 25 0 25 25
P2 4 25 29 29
P3 3 29 32 32
 Formula:
 Completion Time: Time at which process completes its
execution.
 Turn Around Time: Turn Around Time = Completion Time –
Arrival Time.
 Waiting Time(W.T): Waiting Time = Turn Around Time –
Burst Time.
Average waiting time = (0+25+29)/3
= 18millisecond.
Average T.A.T = (25+29+32)/3
FCFS CPU Scheduling With Arrival Time
17
Process Arrival Time Burst Time
P0 0 2
P1 1 6
P2 2 4
P3 3 9
P4 4 12
Process:
Process Arrival Time Burst Time
P0 0 2
P1 1 6
P2 2 4
P3 3 9
P4 4 12
The processes arrive in the order P1, P2, P3 and P4 are served as per
the FCFS algorithm. The Gantt chart is as shown:
P0 P1 P2 P3 P4
8 12 21 330 2
Fig: Gantt chart
19
Process Arrival Time Burst Time Completion
Time
Waiting Time Turn Around
Time
P0 0 2 2 0 2
P1 1 6 8 1 7
P2 2 4 12 6 10
P3 3 9 21 9 18
P4 4 12 33 17 29
 Formula:
 Completion Time: Time at which process completes its
execution.
 Turn Around Time: Turn Around Time = Completion Time –
Arrival Time.
 Waiting Time(W.T): Waiting Time = Turn Around Time – Burst
Time.
Average waiting time = (0+1+6+9+17) / 5
= 6.6ms.
Average T.A.T = (2+7+10+18+29) / 5
Thanks Everyone
THE END
20

Cpu scheduling

  • 1.
    University of Science& Technology Chittagong Course title: Operating Systems Course code: CSE 327 Department of Computer Science & Engineering (CSE) 1 Submitted by : Piku Das (17010110) Mizanur Rahman (17010108) Israt Liza (17010111) Eftykher Mahmud( 17010112) Sushmita Dey (17010113) Batch No : 29 Submitted to : Fatema Tuj Zohra (Lecturer of CSE Department) | |
  • 2.
  • 3.
    Why CPU scheduling? One of the key goal of an operating system is to utilize the the CPU as much as possible. There is a situation for underutilization of CPU because most of the component of a computer is not as fast as the microprocessor. To overcome the problem of underutilization of CPU and main memory, the multiprogramming was introduced. The objective of multiprogramming is to have some process running all the time. 3
  • 4.
    Why CPU scheduling? (cont… .) So to implement the concept of multiprogramming we need to design scheduling algorithms. Whenever the CPU becomes idle , the OS must choose one of the process in the ready queue to be executed . The selection process is carried out by a short term scheduler or CPU scheduler . 4
  • 5.
    5 Preemptive Vs Non-Preemptive PreemptiveNon-Preemptive 1. Allocation For Resource to process for Limited Time. 1. Process holds the resource till Terminated or Switch to Waiting State. 2. Process Can be Interrupted in between 2. Process Can’t be Interrupted until it terminated or switching waiting state 3. High CPU Utilization 3. Low CPU Utilization 4. In Preemptive Scheduling, a running process may be replaced by a higher priority process at any time 4. In Non- Preemptive Scheduling, Once the CPU has been allocated to a process ,the process keeps the CPU it releases the CPU either by terminated by switching the
  • 6.
    6 Preemptive Non-Preemptive 5. PreemptiveScheduling is Flexible 5. Preemptive Scheduling is Rigid 6. Preemptive Scheduling is more Complex 6. Non-Preemptive Scheduling is Simple but it is less efficient 7. Preemptive Scheduling is not attractive 7. Non-Preemptive Scheduling is more attractive because of its simplicity 8. Preemptive Scheduling is cost associative 8. Non-Preemptive Scheduling is not cost associative Preemptive Vs Non-Preemptive
  • 7.
    7 9.Used in timesharing System 9.Not suitible for time sharing System. 10.Switching Overhead 10.Not Switching Overhead 11.SJF (Shortest Job First ) Scheduling, Round Robin Scheduling 11. FCFS(First come First Serve) Preemptive Vs Non-Preemptive
  • 8.
    8 CPU Scheduling Criteria SchedulingCriteria:  There are several different criteria to consider when trying to select the "best" scheduling algorithm for a particular situation and environment, including:  CPU utilization - Ideally the CPU would be busy 100% of the time, so as to waste 0 CPU cycles. On a real system CPU usage should range from 40% ( lightly loaded ) to 90% ( heavily loaded. )  Number of processes completed per unit time. May range from 10 / second to 1 / hour depending on the specific processes.
  • 9.
    9  Turnaround time- Time required for a particular process to complete, from submission time to completion. ( Wall clock time. )  Waiting time - How much time processes spend in the ready queue waiting their turn to get on the CPU. ( Load average - The average number of processes sitting in the ready queue waiting their turn to get into the CPU.  Reported in 1-minute, 5-minute, and 15-minute averages by "uptime" and "who". ) Response time - The time taken in an interactive program from the issuance of a command to the commence of a response to that command. CPU Scheduling Criteria
  • 10.
    10 In general onewants to optimize the average value of a criteria ( Maximize CPU utilization and throughput, and minimize all the others. ) However some times one wants to do something different, such as to minimize the maximum response time.  Sometimes it is most desirable to minimize the variance of a criteria than the actual value. I.e. users are more accepting of a consistent predictable system than an inconsistent one, even if it is a little bit slower. CPU Scheduling Criteria
  • 11.
    What is FCFS? FCFS or First come first serve is an operating system process Scheduling algorithm that automatically executes queued requests and processes by order of their arrival. 5
  • 12.
    i. Jobs areexecuted on first come, first serve basis. ii. It is an non-preemptive scheduling algorithm. iii.It’s implementation is based on FIFO queue. iv.OS runs the process at head of the queue. FCFS Basic Concepts 12 Two kinds of non-preemptive FCFS  With priority scheme.  No priority scheme.
  • 13.
    Advantages 13 i. Simple Algorithm. ii.It is simple to understand and code. iii. Suitable for batch system. i. Because of non-preemptive algorithm the waiting time can be large if short request behind the long process. ii. Not suitable for sharing system. iii. Because of long average waiting time the performance is poor. Disadvantages
  • 14.
    FCFS CPU SchedulingAlgorithm Without Arrival Time 14
  • 15.
    Process: The processes arrivein the order P1, P2, P3 and are served as per the FCFS algorithm. The Gantt chart is as shown: P1 P2 P3 0 25 29 32 Fig: Gantt Chart
  • 16.
    16 Process Burst TimeWaiting Time Completion Time Turn Around Time P1 25 0 25 25 P2 4 25 29 29 P3 3 29 32 32  Formula:  Completion Time: Time at which process completes its execution.  Turn Around Time: Turn Around Time = Completion Time – Arrival Time.  Waiting Time(W.T): Waiting Time = Turn Around Time – Burst Time. Average waiting time = (0+25+29)/3 = 18millisecond. Average T.A.T = (25+29+32)/3
  • 17.
    FCFS CPU SchedulingWith Arrival Time 17 Process Arrival Time Burst Time P0 0 2 P1 1 6 P2 2 4 P3 3 9 P4 4 12
  • 18.
    Process: Process Arrival TimeBurst Time P0 0 2 P1 1 6 P2 2 4 P3 3 9 P4 4 12 The processes arrive in the order P1, P2, P3 and P4 are served as per the FCFS algorithm. The Gantt chart is as shown: P0 P1 P2 P3 P4 8 12 21 330 2 Fig: Gantt chart
  • 19.
    19 Process Arrival TimeBurst Time Completion Time Waiting Time Turn Around Time P0 0 2 2 0 2 P1 1 6 8 1 7 P2 2 4 12 6 10 P3 3 9 21 9 18 P4 4 12 33 17 29  Formula:  Completion Time: Time at which process completes its execution.  Turn Around Time: Turn Around Time = Completion Time – Arrival Time.  Waiting Time(W.T): Waiting Time = Turn Around Time – Burst Time. Average waiting time = (0+1+6+9+17) / 5 = 6.6ms. Average T.A.T = (2+7+10+18+29) / 5
  • 20.