CS 111 Lecture 7 4/23

By: Kacey Ryan, Greg Futami, Nick Westman, Alex Sanciangco


 Access to time / CPU



 Threads (Review from last time)



Scheduling the CPU (solving the above "hard" problem)



Scheduling Issues



How to measure quality of a scheduler

The image shows how to measure scheduling with names for measurement quantities
The figure above shows measurements for scheduling, metrics which were pulled from classic manufacturing.



Types of Schedulers


  1. First Come First Serve (FCFS / FIFO)
    Job Arrival Run Wait Turnaround Time
    A 0 5 0 5
    B 1 2 4+S 6+S
    C 2 9 5+2S 14+2S
    D 3 4 13+3S 17+3S

    let S=scheduling time

    Average run time: 5
    Average wait time: 5.5 + 1.5S
    Average turnaround time: 10.5 + 1.5S

    + fair
    - convoy effect (long/slow jobs slow down shorter jobs after it)


  2. Shortest Job First (SJF)
    Job Arrival Run Wait Turnaround Time
    A 0 5 0 5
    B 1 2 4+S 6+S
    C 2 9 9+3S 18+3S
    D 3 4 4+2S 8+2S

    let S=scheduling time

    Average run time: 4.25
    Average wait time: 5.5 + 1.5S
    Average turnaround time: 9.25 + 1.5S

    + optimizes wait time
    - fairness issue (big jobs can starve)

  3. Priority scheduling
  4. Preemption + scheduling