Docsity

les algorithmes d'ordnnacement des processus, Notes de Systèmes d'exploitation

Aperçu partiel du texte

Télécharge les algorithmes d'ordnnacement des processus et plus Notes au format PDF de Systèmes d'exploitation sur Docsity uniquement!

[ 05 ] SCHEDULING ALGORITHMS

OUTLINE

First-Come First-Served Shortest Job First Shortest Response Time First Predicting Burst Length Round Robin Static vs Dynamic Priority

EXAMPLE: FCFS

Consider the average waiting time under different arrival orders , , : Waiting time , , Average waiting time: , , : Waiting time , , Average waiting time: Arriving in reverse order is three times as good! The first case is poor due to the convoy effect : later processes are held up behind a long-running first process FCFS is simple but not terribly robust to different arrival processes

SHORTEST JOB FIRST (SJF)

Intuition from FCFS leads us to shortest job first (SJF) scheduling Associate with each process the length of its next CPU burst Use these lengths to schedule the process with the shortest time Use, e.g., FCFS to break ties

SHORTEST REMAINING-TIME FIRST (SRTF)

Simply a preemptive version of SJF: preempt the running process if a new process arrives with a CPU burst length less than the remaining time of the current executing process

EXAMPLE: SRTF

As before: Process Arrival Time Burst Time Waiting time for , , , Average waiting time:

PREDICTING BURST LENGTHS

For both SJF and SRTF require the next "burst length" for each process means we must estimate it Can be done by using the length of previous CPU bursts, using exponential averaging:

  1. = actual length of CPU burst.
  2. = predicted value for next CPU burst.
  3. For define:

PREDICTING BURST LENGTHS

If we expand the formula we get: where is some constant Choose value of according to our belief about the system, e.g., if we believe history irrelevant, choose and then get In general an exponential averaging scheme is a good predictor if the variance is small Since both and are less than or equal to one, each successive term has less weight than its predecessor NB. Need some consideration of load, else get (counter-intuitively) increased priorities when increased load

ROUND ROBIN: PROPERTIES

Round robin has some nice properties: Fair: given n processes in the ready queue and time quantum q, each process gets of the CPU Live: no process waits more than time units before receiving a CPU allocation Typically get higher average turnaround time than SRTF, but better average response time But tricky to choose the correct size quantum, : too large becomes FCFS/FIFO too small becomes context switch overhead too high

PRIORITY SCHEDULING

Associate an (integer) priority with each process, e.g., Prio Process type 0 system internal processes 1 interactive processes (staff) 2 interactive processes (students) 3 batch processes Simplest form might be just system vs user tasks

TIE-BREAKING

What do with ties? Round robin with time-slicing, allocating quantum to each process in turn Problem: biases towards CPU intensive jobs (Why?) Solution? Per-process quantum based on usage? Just ignore the problem?

STARVATION

Urban legend about IBM 7074 at MIT: when shut down in 1973 , low-priority processes were found which had been submitted in 1967 and had not yet been run... This is the biggest problem with static priority systems: a low priority process is not guaranteed to run — ever!

EXAMPLE: COMPUTED PRIORITY

First used in Dijkstra's THE Timeslots: In each time slot , measure the CPU usage of process Priority for process in slot : E.g., Penalises CPU bound but supports IO bound Once considered impractical but now such computation considered acceptable

3 SUMMARY First-Come First-Served Shortest Job First Shortest Response Time First Predicting Burst Length Round Robin Static vs Dynamic Priority