CPU Scheduling: Algorithms and Systems, Study notes of Computer Science

An overview of cpu scheduling algorithms and systems, including first-come-first-serve (fcfs), shortest job first (sjf), priority scheduling, round robin (rr), and multilevel feedback queues. Real-world scheduling systems like solaris and linux are also discussed.

Typology: Study notes

Pre 2010

Uploaded on 09/24/2009

koofers-user-fve-1
koofers-user-fve-1 🇺🇸

10 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Operating Systems
Operating Systems
CMPSC 473
CMPSC 473
CPU Scheduling
CPU Scheduling
February 14, 2008 - Lecture
February 14, 2008 - Lecture
9
9
Instructor: Trent Jaeger
Instructor: Trent Jaeger
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download CPU Scheduling: Algorithms and Systems and more Study notes Computer Science in PDF only on Docsity!

Operating SystemsOperating Systems

CMPSC 473 CMPSC 473

CPU Scheduling CPU Scheduling

February 14, 2008 - Lecture February 14, 2008 - Lecture 99

Instructor: Trent Jaeger Instructor: Trent Jaeger

  • Last class:
    • CPU Scheduling
  • Today:
    • CPU Scheduling Algorithms and Systems

Priority Scheduling

• Each process is given a certain priority

“value”.

• Always schedule the process with the highest

priority.

P5 5 2

P4 1 5

P3 2 4

P2 1 1

P1 10 3

Duration(s) Priority

Gantt Chart for Priority Scheduling

P 0 1 P 6 P 16 P 18 P 19

Round Robin (RR)

  • Each process gets a small unit of CPU time ( time

quantum )

  • Usually 10-100 milliseconds
  • After this time has elapsed, the process is preempted and added to the end of the ready queue
  • Approach
  • If there are n processes in the ready queue and the time quantum is q
  • Then each process gets 1/ n of the CPU time
  • In chunks of at most q time units at once.
  • No process waits more than ( n -1) q time units

An example of Round Robin

P3 0 7

P2 0 3

P1 0 24

Job length (s) Arrival Time (s) Time Quantum = 4 s P (^0 ) P 7 P 11 P 15 P 18 P 22 P 26 P 30 P 34

RR Time Quantum

• For the considered example, if time quantum

size drops to 2s from 4s, the number of

context switches increases to ????

• But context switches are not free!

– Saving/restoring registers

– Switching address spaces

– Indirect costs (cache pollution)

Scheduling Desirables

  • SJF
    • Minimize waiting time
      • Requires estimate of CPU bursts
  • Round robin
    • Share CPU via time quanta
      • If burst turns out to be “too long”
  • Priorities
    • Some processes are more important
    • Priorities enable composition of “importance” factors
  • No single best approach -- now what?

Round-Robin with Priority

Priority Levels

What is the problem?

• With fixed priorities, processes lower in the

priority level can get starved out!

• In general, you employ a mechanism to “age”

the priority of processes.

Example of Multilevel

Feedback Queue

  • Three queues:
    • Q 0 – RR with time quantum 8 milliseconds
    • Q 1 – RR time quantum 16 milliseconds
    • Q 2 – FCFS
  • Scheduling
    • A new job enters queue Q 0 which is served FCFS. When it gains CPU, job receives 8 milliseconds. If it does not finish in 8 milliseconds, job is moved to queue Q 1.
    • At Q 1 job is again served FCFS and receives 16 additional milliseconds. If it still does not complete, it is preempted and moved to queue Q 2.

Multilevel Feedback Queues

Solaris 2 Scheduling

Solaris Dispatch Table