Scheduling_algorithms notes
Scheduling_algorithms notes
1.2.1d
Recap: Multitasking.
The illusion that multiple processes are running simultaneously,
where in reality they are running serially.
What is scheduling?
Deciding which process should go next after one is done.
Why?
Allow priorities.
Process
states:
Scheduling algorithms 1
Running
= process currently running by CPU
Ready
to run = a queue where processes currently waiting for
processor time.
Blocked
= processes which cannot continue due to waiting for an
external resource or an interrupt.
Scheduling algorithms 2
The process blocks.
First
Come First Serve Algorithm.
Run each process in order for as long as it wants.
Advantage:
Fair system.
Disadvantages:
Round
Robin Algorithm.
FCFS + give each process a time to run.
Advantages:
Fair system.
Disadvantages:
Scheduling algorithms 3
Shortest
Job First Algorithm.
Insert and arrange processes into time order before running,
shortest process first.
Advantages:
Disadvantages:
Scheduling algorithms 4
Scheduling algorithms 5
Multi level feedback queues
Scheduling algorithms 6
Evaluating scheduling algorithms
SRT (Shortest FCFS (First
RR (Round SJF (Shortest
MLFQ Remaining Come First
Robin) Job First)
Time) Serve)
Yes/No - may
No - depends No - can have
vary based on
Yes - time on job length, Yes - short long waiting
priority
Responsiveness slices ensure can cause processes are times,
adjustments
responsiveness. delay for longer given priority. especially for
and process
processes. longer jobs.
aging.
Wait Time Yes - can Moderate - Low for short Low for short High -
optimise wait depends on jobs but high jobs, but may especially if a
times with number of for long jobs. grow for longer long process
aging and processes and jobs due to arrives first.
dynamic time slices. preemption.
Scheduling algorithms 7
SRT (Shortest FCFS (First
RR (Round SJF (Shortest
MLFQ Remaining Come First
Robin) Job First)
Time) Serve)
priority
adjustment.
Summary
MLFQ (Multi-Level Feedback Queue): Uses a dynamic priority system, allowing processes
to move between queues based on behavior. It offers fairness but can still lead to starvation
if lower-priority processes don't get attention.
RR (Round Robin): Distributes CPU time evenly in fixed-sized time slices, ensuring fairness
and responsiveness but not necessarily optimizing for the shortest jobs.
SJF (Shortest Job First): Focuses on executing the shortest jobs first, leading to minimal
waiting time for those jobs, but can starve longer processes.
SRT (Shortest Remaining Time): Similar to SJF but preemptive, focusing on jobs that have
the shortest remaining time. Short jobs get priority, possibly starving longer ones.
FCFS (First Come, First Serve): Executes processes in the order they arrive. It’s fair but can
lead to high wait times, especially for longer processes that arrive before shorter ones.
Scheduling algorithms 8