0% found this document useful (0 votes)
3 views

Scheduling_algorithms notes

Uploaded by

talkhardik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Scheduling_algorithms notes

Uploaded by

talkhardik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Scheduling algorithms

Created @March 2, 2024 6:49 PM

Class Operating system

Reviewed Not started

1.2.1d

Scheduling: round robin, first come first served, multi-level


feedback queues, shortest job first and shortest remaining time.

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?

Maximise throughput of processes.

Maximise the use of the CPU.

Minimise starvation (when a resource is continuously being used


leading to another process not getting a chance to use it) and eliminate
deadlock (when items are waiting for a resource which may never become
free).

Ensure fairness for processes.

Be responsive for the end user.

Allow priorities.

Use I/O devices efficiently.

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.

A process runs until...


The process closes.

The scheduler pre-empts the process.

The process gives up CPU voluntarily.

Scheduling algorithms 2
The process blocks.

First
Come First Serve Algorithm.
Run each process in order for as long as it wants.

Allow a process to block.

Advantage:

Simple implementation with a queue data structure.

Good with short runtime processes.

Fair system.

Disadvantages:

Bad for long processes who monopolise the CPU.

No throughput maximisation for longer processes.

Therefore lack of responsiveness to user.

Does not prioritise blocked processes.

Round
Robin Algorithm.
FCFS + give each process a time to run.

If process uses up its time allocation (pre-empted), return to


the back of the queue.

Advantages:

Simple implementation with a queue data structure.

Prevents monopolisation of CPU from longer processes, improving


throughput.

Fair system.

Disadvantages:

Poor performance with lots of processes, leading to lack of


responsiveness.

No priority for blocked processes.

Admin cost from swapping processes if time assigned to a process


is too small.

Scheduling algorithms 3
Shortest
Job First Algorithm.
Insert and arrange processes into time order before running,
shortest process first.

Advantages:

Prioritise processes that will end up being blocked.

Usually GUI operation and accessing I/O devices.

Leads to improved throughput of processes.

Disadvantages:

May suffer from starvation from longer processes.

Not as fair as other algorithms.

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 - adjusts to Yes - executes


No - favors
process Yes - gives No - can starve processes in
shorter jobs,
priorities, each process longer jobs if arrival order,
Fairness possibly
ensuring fair equal time shorter jobs but can be
starving longer
distribution of slices. arrive. unfair for short
ones.
CPU time. processes.

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.

Yes - longer Yes - long


Yes - lower No - each Yes - short jobs
jobs may be processes may
priority jobs process gets an are preferred;
Starvation starved if suffer if shorter
may be equal slice of long ones may
shorter jobs ones arrive
starved. time. be starved.
keep arriving. first.

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

You might also like