0% found this document useful (0 votes)
21 views13 pages

Week 4b

Os Notes
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)
21 views13 pages

Week 4b

Os Notes
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/ 13

CPU Scheduling

Operating System Concepts – 8th Edition, Silberschatz, Galvin and Gagne ©2009
Chapter 5: CPU Scheduling
 To introduce CPU scheduling, which is the basis for multi-
programmed operating systems
 To describe various CPU-scheduling algorithms

 This is the most interesting topic in Process Management


 You will come across many numerical problems also.

Operating System Concepts – 8th Edition 5.2 Silberschatz, Galvin and Gagne ©2009
Basic Concepts
 How do we obtain maximum CPU
utilization?
 with multiprogramming
 CPU–I/O Burst Cycle – Process
execution consists of a cycle of
CPU execution and I/O wait

Operating System Concepts – 8th Edition 5.3 Silberschatz, Galvin and Gagne ©2009
CPU Scheduler
 Selects from among the processes in memory that are ready
to execute, and allocates the CPU to one of them
 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
 Scheduling under 1 and 4 is nonpreemptive
 All other scheduling is preemptive

Operating System Concepts – 8th Edition 5.4 Silberschatz, Galvin and Gagne ©2009
Non preemptive scheduling
 Under nonpreemptive scheduling, once the CPU has
been allocated to a process, the process keeps the CPU
until it releases the CPU either by terminating or by
switching to the waiting state.
 Windows 3.1 and Apple Mac use this.

Operating System Concepts – 8th Edition 5.5 Silberschatz, Galvin and Gagne ©2009
Preemptive scheduling
 A process may be preempted i.e. forced to leave the CPU.
 Synchronization mechanisms required for processes
sharing data
 OS kernel design to take care of processes preempted
when kernel data structures are inconsistent (in the middle
of a system call).

Operating System Concepts – 8th Edition 5.6 Silberschatz, Galvin and Gagne ©2009
Dispatcher
 Dispatcher module 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
restart that program
 Dispatch latency – time it takes for the dispatcher to
stop one process and start another running

Operating System Concepts – 8th Edition 5.7 Silberschatz, Galvin and Gagne ©2009
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
 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)

Operating System Concepts – 8th Edition 5.8 Silberschatz, Galvin and Gagne ©2009
Scheduling Algorithm Optimization Criteria

 Max CPU utilization


 Max throughput
 Min turnaround time
 Min waiting time
 Min response time

Operating System Concepts – 8th Edition 5.9 Silberschatz, Galvin and Gagne ©2009
Scheduling Issues / Criteria
 Fairness
 Don’t starve process
 Priorities
 Most important first
 Deadlines
 Task X must be done by time t
 Optimization
 Throughput, response time
 Reality - No universal scheduling policy
 Many scheduling models

Operating System Concepts – 8th Edition 5.10 Silberschatz, Galvin and Gagne ©2009
Note
 We will discuss scheduling algorithms in two contexts
 Preemptive scheduling: The CPU scheduler can interrupt
a running process (involuntary context switch)
 Non-preemptive scheduling: The CPU scheduler waits for
a running job to terminate or block (voluntary context
switch)

Operating System Concepts – 8th Edition 5.11 Silberschatz, Galvin and Gagne ©2009
Gantt Chart
 A Gantt chart is a graphical representation of the duration of tasks
against the progression of time.
 A Gantt chart is a useful tool for planning, scheduling and
monitoring projects progress.

 When evaluating a scheduler’s performance, we use a Gantt


Chart.
 This is a horizontal timeline indicating which processes are
run and at what times they run starting from when all tasks
are submitted and ending when all tasks have been
completed.

Operating System Concepts – 8th Edition 5.12 Silberschatz, Galvin and Gagne ©2009
Scheduling Algorithms

1. First come, First served


2. Shortest Job First
3. Priority Scheduling
4. Round-Robin Scheduling
5. Multi-level Queue Scheduling
6. Multi-level Feed back queue Scheduling

14
Operating System Concepts – 8th Edition 5.13 Silberschatz, Galvin and Gagne ©2009

You might also like