CPU Scheduling: Concepts, Algorithms, and Evaluation, Slides of Operating Systems

An in-depth exploration of cpu scheduling, covering basic concepts, scheduling criteria, algorithms, and multiple-processor scheduling. It includes examples and evaluations of various scheduling methods such as first-come-first-served (fcfs), shortest-job-first (sjf), and round robin (rr).

Typology: Slides

2012/2013

Uploaded on 04/24/2013

banamala
banamala 🇮🇳

4.4

(19)

114 documents

1 / 57

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CPU SCHEDULING
Basic Concepts
Scheduling Criteria
Scheduling Algorithms
Multiple-Processor Scheduling
Algorithm Evaluation
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
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39

Partial preview of the text

Download CPU Scheduling: Concepts, Algorithms, and Evaluation and more Slides Operating Systems in PDF only on Docsity!

CPU SCHEDULING

Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Algorithm Evaluation

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.
  • CPU burst distribution

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:
    • Switches from running to waiting state.
    • Switches from running to ready state.
    • Switches from waiting to ready.
    • Terminates.
  • 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)

First-Come, First-Served (FCFS)

Process Burst Time P1 24 P2 3 P3 3

  • Suppose that the processes arrive in the order: P1 , P2 , P. The Gantt Chart for the schedule is:
  • Waiting time for P1 = 0; P2 = 24; P3 = 27
  • Average waiting time: (0 + 24 + 27)/3 = 17

P 1 P 2 P 3 0 24 27 30

FCFS Scheduling (Cont.)

  • Suppose that the processes arrive in the order P2 , P3 , P
  • The Gantt chart for the schedule is:
  • Waiting time for P1 = 6; P2 = 0; P3 = 3
  • Average waiting time: (6 + 0 + 3)/3 = 3
  • Much better than previous case.

P 2 P 3 P 1 0 3 6 30

Shortest-Job-First (SJF) Scheduling

  • Preemptive Version (SRTF)
    • if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest- Remaining-Time-First (SRTF).
  • SJF is optimal – gives minimum average waiting time for a given set of processes.

Example of Non-Preemptive SJF

Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4

  • SJF (non-preemptive)
  • Average waiting time = (0 + 6 + 3 + 7)/4 = 4

P 1 P 3 P 2 0 3 7 16

P 4 8 12

Docsity.com

Predicting Next CPU Burst

  • The exponential average formula can only estimate the length.
  • Can be done by using the length of previous CPU bursts, using exponential averaging.
  1. Define:
  2. , 0 1
  3. predicted value for the next CPUburst
  4. actual lenght of CPUburst

 

   

 (^) n 1

th tn n

 n  1  tn   1   n.

actual length

Next CPU Burst

Exponential Averaging

  • If we expand the formula, we get: n+1 =  tn+(1 - ) n n+1 =  tn+(1 - )[  tn-1 +(1 - ) n-1 ] + … +(1 -  )j  tn-j + … +(1 -  )n+1  0
  • Since both  and (1 - ) are less than or equal to 1, each successive term has less weight than its predecessor.

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