Scheduling

Decide which process to run

Which process should the kernel run?

  • if 0 are runnable → run idle loop or halt CPU
  • if 1 is runnable → run it
  • if >1 are runnable → must make scheduling decision about which process to run
    • We could use a queue for runnable processes

When to pre-empt?

Can preempt a process when control is passed to the OS Kernel

Device interrupt

  • Disk request complete, packet arrived on network
    • Previously waiting task becomes runnable
  • Schedule if higher priority

Changing the running process is called a Context Switch

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 new/waiting to read
  4. exits
    Non-preemptive schedules use 1 and 4 only
    See also Process states

Scheduling Criteria

Bursts of Computation and I/O

Jobs contain I/O and computation

Approach 1: FCFS Scheduling

Approach 2: SJF Scheduling

Approach 3: Round Robin Scheduling

Approach 4: Priority Scheduling

Approach 5: Borrowed Virtual Time Scheduler

Multiprocessor Scheduling Issues

The scheduler also needs to decide on which CPU/core runs which process

Affinity scheduling

Context Switch Costs

Direct cost

Indirect Costs

Time Quantum

Thread Dependencies