Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Operating Systems 10

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 21

Operating system

Lecture 10
Agenda for Today
 Review of previous lecture
 Short-term scheduler
 Dispatcher
 Reasons for invoking scheduler
 Optimization criteria
 FCFS
CPU Scheduling

 Scheduling processes in the


ready queue
 Short-term scheduler
 Different types of schedulers
Life of a Process
Histogram of CPU-burst
Times
CPU Scheduler
Short-term scheduler
Selects a process from among the
processes in the ready queue
Invokes the dispatcher to have
the CPU allocated to the selected
process
Dispatcher
 Dispatcher gives control of the CPU
to the process selected by the
short-term scheduler; this involves:
 switching context
 switching to user mode
 jumping to the proper location in
the user program to start (or
restart) it
Dispatcher
 Dispatch latency – time it takes
for the dispatcher to stop one
process and start another
running.
 Typically, a few microseconds
CPU Scheduler
 CPU scheduling decisions may take
place when a process:
1. Switches from running to waiting
state
2. Switches from running to ready
state
3. Switches from waiting to ready
4. Terminates
CPU Scheduler
 Scheduling under 1 and 4 is
nonpreemptive.
 All other scheduling is preemptive.
Scheduling Criteria
CPU utilization – keep the CPU as
busy as possible
Throughput – # of processes that
complete their execution per time
unit
Turnaround time – amount of time to
execute a particular process
Scheduling Criteria
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)
Optimization Criteria
Maximize CPU utilization
Maximize throughput
Minimize turnaround time
Minimize waiting time
Minimize response time
FCFS Scheduling
The process that enters the ready queue
first is scheduled first, regardless of the
size of its next CPU burst
Example: Process Burst Time
P1 24
P2 3
P3 3
Suppose that processes arrive into the
system in the order: P1, P2 , P3
FCFS Scheduling
Processes are served in the order: P1, P2, P3
The Gantt Chart for the schedule is:

P1 P2 P3

0 24 27 30

Waiting times P1 = 0; P2 = 24; P3 = 27


Average waiting time: (0+24+27)/3 = 17
FCFS Scheduling
 Suppose that 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
 Convoy effect short process behind long
process
FCFS Scheduling Example
Solution
Solution
Problems with FCFS Scheduling

• It is Non Pre-emptive algorithm, which means the process


priority doesn't matter.If a process with very least priority is being
executed, more like daily routine backup process, which takes more
time, and all of a sudden some other high priority process arrives,
like interrupt to avoid system crash, the high priority process will
have to wait, and hence in this case, the system will crash, just
because of improper process scheduling.
• Not optimal Average Waiting Time.
• Resources utilization in parallel is not possible, which leads to Convoy
Effect, and hence poor resource(CPU, I/O etc) utilization.
What is Convoy Effect?

• Convoy Effect is a situation where many processes, who need to use a


resource for short time are blocked by one process holding that
resource for a long time.
• This essentially leads to poort utilization of resources and hence poor
performance.

You might also like