CPU Scheduling: Max CPU Utilization, Three-Level Scheduling, and Algorithms, Slides of Operating Systems

The concepts of cpu scheduling, including maximum cpu utilization with multiprogramming, cpu-i/o burst cycle, three-level scheduling, and various cpu scheduling algorithms such as first-come-first-served (fcfs), shortest-job-first (sjf), and round robin (rr). It also discusses scheduling criteria and optimization criteria.

Typology: Slides

2012/2013

Uploaded on 04/25/2013

baidehi
baidehi 🇮🇳

4.4

(14)

101 documents

1 / 36

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 9
Chapter 5: CPU Scheduling (cont)
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24

Partial preview of the text

Download CPU Scheduling: Max CPU Utilization, Three-Level Scheduling, and Algorithms and more Slides Operating Systems in PDF only on Docsity!

Lecture 9

Chapter 5: CPU Scheduling (cont)

Basic Concepts

  • Maximum CPU utilization obtained with multiprogramming
  • CPU–I/O Burst Cycle : Process execution consists of a cycle of CPU execution and I/O wait - Alternating Sequence of CPU and I/O Bursts
  • Histogram of CPU-burst Times

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
    • Processes keep CPU until it releases either by terminating or I/O wait.
  • All other scheduling is preemptive
    • Interrupts

cooperative scheduling  let a process run until it blocks on I/O, terminates or voluntarily releases the CPU (system call) Ready Running Blocke d

Ready Running Blocke d

preemptive scheduling  follow clock interrupts (ex: 50Hz) to forcibly switch processes (demote the “Running” to “Ready”)

Two kinds of CPU-scheduling algorithms

Scheduling Criteria

  • CPU utilization – keep the CPU as busy as possible - Typically between 40% to 90%
  • Throughput – # of processes that complete their execution per time unit - Depends on the length of process
  • Turnaround time – amount of time to execute a particular process - Sum of wait for memory, ready queue, execution, and I/O.
  • Waiting time – amount of time a processDocsity.com

Scheduling Algorithm Optimization Criteria

  • Max CPU utilization
  • Max throughput
  • Min turnaround time
  • Min waiting time
  • Min response time
  • In most cases, systems optimize average measure

Shortest-Job-First (SJF) Scheduling

  • Associate with each process the length of its next CPU burst. - Use these lengths to schedule the process with the shortest time - shortest-next-CPU-burst
  • SJF is optimal
    • Gives minimum average waiting time for a given set of processes
    • The difficulty is knowing the length of the next CPU request

A B C D E

Arrival times

Shortest JobFirst (SJF)

SJF^ A^ B^ C^ D^ E^ Mean

Determining Length of Next CPU

Burst

  • Can only estimate the length
  • Can be done by using the length of previous CPU bursts - using exponential averaging 4. Define : 3. , 0 1 2. predictedvaluefor thenextCPU burst
  1. actual lengthof CPU burst

≤ ≤

=

=

α α

τ (^) n 1

tn nth

τ (^) n = 1 =α tn + ( 1 −α) τ (^) n.

 choose the process whose remaining run time is shortestExample of SJF (preemtive)

 allows new short jobs to get good service

A B C D E Mean

A B C D E

Arrival times

Priority Scheduling

  • A priority number (integer) is associated with each process
  • The CPU is allocated to the process with the highest priority (smallest integer ≡ highest priority) - Preemptive - Nonpreemptive
  • SJF is a priority scheduling where priority is

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.
  • 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.Docsity.com

Examples of RR

A B C D E

Arrival times

A B C D E Mean

A B C D E Mean

Turnaround Time Varies With The Time Quantum

Multilevel Queue

  • Ready queue is partitioned into separate queues: - foreground (interactive) - background (batch)
  • Each queue has its own scheduling algorithm
    • foreground – RR
    • background – FCFS
  • Scheduling must be done between the queues
    • Fixed priority scheduling;