Vous êtes sur la page 1sur 127

Ordonnancement des processus

SYSTÈMES D’EXPLOITATION
AVANCÉES

Ce cours est fortement inspiré de celui de Uğur HALICI


(http://www.eee.metu.edu.tr/~halici/courses/442/Ch2%20Process%20Scheduling.pdf)
Critères d’Ordonnancement

• Utilisation du CPU
• Débit (Throughput)
• Temps de rotation (Turnaround time)
• Temps d’attente
• Temps de réponse

Nadia Bel Hadj Aissa 2


Critères d’optimisation: max/min
• Les critères d’ordonnancement peuvent être ramenés à des
problèmes d’optimisation. Chaque critère devra être maximisé
ou minimisé.
• Utilisation du CPU

même temps??
Peuvent-ils tous être optimisés en
– Maximiser
• Débit (Throughput)
– Maximiser
• Temps de rotation (Turnaround time)
– Minimiser
• Temps d’attente
– Minimiser
• Temps de réponse
– Minimiser

Nadia Bel Hadj Aissa 3


Avec/Sans réquisition
• Ordonnancement sans réquisition (non préemptif):
– Une fois que le CPU a été allouée à un processus, ce dernier le
garde jusqu'à ce qu’il le libère, soit parce qu’il a terminé, soit
parce qu’il commute à l’état en attente.
– Algorithmes simples et faciles à mettre en œuvre mais pas
adaptés pour le temps partagé et seulement pour les système
de traitement par lots.
• Ordonnancement avec réquisition (préemptif):
– Un processus peut être suspendu à n’importe quel instant,
sans avoir été prévenu, pour laisser la place à un autre
processus.
– Implémentation plus couteuse à cause de la commutation de
processus, utilisée dans les systèmes à temps partagé et
systèmes temps-réels.
– Nécessité d’un mécanisme de synchronisation.

Nadia Bel Hadj Aissa 4


Exemple

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

5
Ordonnancement sans réquisition
PREMIER ARRIVÉ PREMIER SERVI

Nadia Bel Hadj Aissa 6


FIFO (First In First Out)
• Allocation dans l’ordre d’arrivée (premier
arrivé = premier servi)
Processus durée
P1 24
P2 3
P3 3
• L’ordre d’arrivée est: P1 , P2 , P3
P1 P2 P3

0 24 27 30
• Le temps d’attente pour P1 = 0; P2 = 24; P3 = 27
• Temps moyen d’attente: (0 + 24 + 27)/3 = 17
Nadia Bel Hadj Aissa 7
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ A
:

8
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ B
:

9
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ B C
:

10
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ B C
:

11
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ C D
:

12
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ C D A
:

13
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ C D A
:

14
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ D A B
:

15
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ D A B
:

16
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ A B C
:

17
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ B C D
:

18
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ B C D
:

19
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ C D A
:

20
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ C D A
:

21
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ D A
:

22
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ: A

23
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ: D

24
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ: D

25
2.3.1 First-Come-First-Served (FCFS)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4 4 4 4 4
B 2 8 1 8 - -
C 3 2 1 2 - -
D 7 1 1 1 1 1

RQ:

26
2.3.1 First-Come-First-Served (FCFS)

• Processor utilization = (35 / 35) * 100 = 100 %


• Throughput = 4 / 35=0.11

27
2.3.1 First-Come-First-Served (FCFS)

• Turn around time:


tatA = 34 – 0 = 34
tatB = 27 – 2 = 25
tatC = 29 – 3 = 26
tatD = 35 – 7 = 28

tatAVG = (34 + 25 + 26 + 28) / 4 = 28.25

28
2.3.1 First-Come-First-Served (FCFS)

• Turn around time:


tatA = 34 – 0 = 34
tatB = 27 – 2 = 25
tatC = 29 – 3 = 26
tatD = 35 – 7 = 28

tatAVG = (34 + 25 + 26 + 28) / 4 = 28.25

29
2.3.1 First-Come-First-Served (FCFS)

• Turn around time:


tatA = 34 – 0 = 34
tatB = 27 – 2 = 25
tatC = 29 – 3 = 26
tatD = 35 – 7 = 28

tatAVG = (34 + 25 + 26 + 28) / 4 = 28.25

30
2.3.1 First-Come-First-Served (FCFS)

• Turn around time:


tatA = 34 – 0 = 34
tatB = 27 – 2 = 25
tatC = 29 – 3 = 26
tatD = 35 – 7 = 28

tatAVG = (34 + 25 + 26 + 28) / 4 = 28.25

31
2.3.1 First-Come-First-Served (FCFS)

• Turn around time:


tatA = 34 – 0 = 34
tatB = 27 – 2 = 25
tatC = 29 – 3 = 26
tatD = 35 – 7 = 28

tatAVG = (34 + 25 + 26 + 28) / 4 = 28.25

32
2.3.1 First-Come-First-Served (FCFS)

• Waiting time:
wtA = (0 – 0) + (15 – 8) + (30 – 23) = 14
wtB = (4 – 2) + (19 – 13) = 8
wtC = (12 – 3) + (27 – 15) = 21
wtD = (14 – 7) + (29 – 16) + (34 – 31) = 23

wtAVG = (14 + 12 + 21 + 23) / 4 = 16.5

33
2.3.1 First-Come-First-Served (FCFS)

• Waiting time:
wtA = (0 – 0) + (15 – 8) + (30 – 23) = 14
wtB = (4 – 2) + (19 – 13) = 8
wtC = (12 – 3) + (27 – 15) = 21
wtD = (14 – 7) + (29 – 16) + (34 – 31) = 23

wtAVG = (14 + 12 + 21 + 23) / 4 = 16.5

34
2.3.1 First-Come-First-Served (FCFS)

• Waiting time:
wtA = (0 – 0) + (15 – 8) + (30 – 23) = 14
wtB = (4 – 2) + (19 – 13) = 8
wtC = (12 – 3) + (27 – 15) = 21
wtD = (14 – 7) + (29 – 16) + (34 – 31) = 23

wtAVG = (14 + 12 + 21 + 23) / 4 = 16.5

35
2.3.1 First-Come-First-Served (FCFS)

• Waiting time:
wtA = (0 – 0) + (15 – 8) + (30 – 23) = 14
wtB = (4 – 2) + (19 – 13) = 8
wtC = (12 – 3) + (27 – 15) = 21
wtD = (14 – 7) + (29 – 16) + (34 – 31) = 23

wtAVG = (14 + 12 + 21 + 23) / 4 = 16.5

36
2.3.1 First-Come-First-Served (FCFS)

• Waiting time:
wtA = (0 – 0) + (15 – 8) + (30 – 23) = 14
wtB = (4 – 2) + (19 – 13) = 8
wtC = (12 – 3) + (27 – 15) = 21
wtD = (14 – 7) + (29 – 16) + (34 – 31) = 23

wtAVG = (14 + 12 + 21 + 23) / 4 = 16.5

37
2.3.1 First-Come-First-Served (FCFS)

• Response time:
rtA = 0 – 0 = 0
rtB = 4 – 2 = 2
rtC = 12 – 3 = 9
rtD = 14 – 7 = 7

rtAVG = (0 + 2 + 9 + 7) / 4 = 4.5

38
2.3.1 First-Come-First-Served (FCFS)

• Response time:
rtA = 0 – 0 = 0
rtB = 4 – 2 = 2
rtC = 12 – 3 = 9
rtD = 14 – 7 = 7

rtAVG = (0 + 2 + 9 + 7) / 4 = 4.5

39
2.3.1 First-Come-First-Served (FCFS)

• Response time:
rtA = 0 – 0 = 0
rtB = 4 – 2 = 2
rtC = 12 – 3 = 9
rtD = 14 – 7 = 7

rtAVG = (0 + 2 + 9 + 7) / 4 = 4.5

40
2.3.1 First-Come-First-Served (FCFS)

• Response time:
rtA = 0 – 0 = 0
rtB = 4 – 2 = 2
rtC = 12 – 3 = 9
rtD = 14 – 7 = 7

rtAVG = (0 + 2 + 9 + 7) / 4 = 4.5

41
2.3.1 First-Come-First-Served (FCFS)

• Response time:
rtA = 0 – 0 = 0
rtB = 4 – 2 = 2
rtC = 12 – 3 = 9
rtD = 14 – 7 = 7

rtAVG = (0 + 2 + 9 + 7) / 4 = 4.5

42
Inconvénients FIFO

• défavorise les entités ayant besoin d’utiliser


la ressource un court laps de temps
• Le temps d’attente n’est pas proportionnel au
temps d’utilisation
⇒ pas équitable,
⇒ temps moyen de traitement élevé

Nadia Bel Hadj Aissa 43


Inconvénients FIFO
– une grande perte de cycles de CPU

CPU (1s) I/O (1ms) I/O (1ms) I/O (1ms) I/O (1ms)

Exécute pour Plusieurs processus tributaire aux E/S


1s à la fois et
bloque Chaque a besoin de faire 1000 lectures au disque, et
bloque immédiatement (temps de CPU court: <1ms)

Si le processus d’E/S a le CPU une fois par seconde cela va prendre


1000 secondes pour que tout les processus complètent! Si le processus
qui est tributaire du CPU donne le CPU tout les 10ms, tous les processus
qui font des E/S finissent en un petit 10 secondes!

Nadia Bel Hadj Aissa 44


ORDONNANCEMENT AVEC
RÉQUISITION

Nadia Bel Hadj Aissa 45


Ordonnancement avec réquisition (préemptifs)
• Pour s’assurer qu’aucun processus ne s’exécute pendant trop
de temps, une horloge génère périodiquement une
interruption.
• A chaque interruption d’horloge, le système d’exploitation
reprend la main et décide si le processus courant doit :
– poursuivre son exécution ou
– être suspendu pour laisser place à un autre.
• S’il décide de suspendre l’exécution au profit d’un autre, il
doit d’abord sauvegarder l’état des registres du processeur
avant de charger dans le registres les données du processus
à lancer (commutation de contexte).
• Cette sauvegarde est nécessaire pour pouvoir poursuivre
ultérieurement l’exécution du processus suspendu.

Nadia Bel Hadj Aissa 46


ALGORITHME DU TOURNIQUET
(ROUND ROBIN)

Nadia Bel Hadj Aissa 47


Algorithme du Tourniquet (Round Robin)
• Algorithme conçu spécialement pour le temps
partagé
• Les processus accèdent au processeur, chacun à
leur tour, pour un temps maximal déterminé à
l’avance (le quantum noté q= en général 10-100
millisecondes),
• Lorsqu’il a épuisé ce temps, ou qu’il se bloque : le
processus suivant est élu et le remplace.
• Le processus suspendu est mis en queue du
tourniquet (file FIFO circulaire).

Nadia Bel Hadj Aissa 48


Algorithme du Tourniquet (Round Robin)

Process Arrival 1ère exec 1s I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:4 4 4:4 4 4:4
B 2 8:8 1 8:8 - -
C 3 2:2 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RR RQ A:4:4 Proc in CPU: Q: 3:0


: next_cpu_burst : remaining_time Time
quantum used

FCFS
49
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:2 4 4:4 4 4:4
B 2 8:8 1 8:8 - -
C 3 2:2 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RR RQ B:8:8 Proc in CPU: A:4:2 Q: 3:2


: next_cpu_burst : remaining_time

FCFS
50
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:1 4 4:4 4 4:4
B 2 8:8 1 8:8 - -
C 3 2:2 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RQ B:8:8 C:2:2 A:4:1 Proc in CPU: A:4:1 Q: 3:3


:
preemption expires
p

51
Etats des processus

 Si plus d’un processus essayent d’entrer en même temps à la file


d’attente des processus prêts, la priorité est donnée comme suit:
 1: processus qui viennent d’être soumis
 2: processus qui ont fini une opération d’E/s
 3: Les processus qui ont été préemptés par le CPU
preeemption
3
1
START READY RUNNING HALTED

I/O 2 I/O
completed requested
WAITING
52
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:1 4 4:4 4 4:4
B 2 8:5 1 8:8 - -
C 3 2:2 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RQ C:2:2 A:4:1 B:8:5 Proc in CPU: B:8:5 Q: 3:3


:
preemption expires
p p

53
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:1 4 4:4 4 4:4
B 2 8:5 1 8:8 - -
C 3 2:1 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RQ A:4:1 B:8:5 D:1:1 Proc in CPU: C:2:1 Q: 3:1


: expires
p p

54
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:1 4 4:4 4 4:4
B 2 8:5 1 8:8 - -
C 3 2:0 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RQ A:4:1 B:8:5 D:1:1 Proc in CPU: Q: 3:0


: expires
p p

55
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:4 4 4:4
B 2 8:5 1 8:8 - -
C 3 2:0 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RQ B:8:5 D:1:1 C:2:2 Proc in CPU: Q: 3:0


: expires
p p

56
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:4 4 4:4
B 2 8:2 1 8:8 - -
C 3 2:0 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RQ D:1:1 C:2:2 B:8:2 Proc in CPU: B:8:2 Q: 3:3


:
preemption expires
p p p

57
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:4 4 4:4
B 2 8:2 1 8:8 - -
C 3 2:0 1 2:2 - -
D 7 1:0 1 1:1 1 1:1

RQ C:2:2 B:8:2 A:4:4 Proc in CPU: Q: 3:0


: expires
p p p

58
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:4 4 4:4
B 2 8:2 1 8:8 - -
C 3 2:0 1 2:1 - -
D 7 1:0 1 1:1 1 1:1

RQ B:8:2 A:4:4 D:1:1 Proc in CPU: C:2:1 Q: 3:1


: expires
p p p

59
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:4 4 4:4
B 2 8:2 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:1 1 1:1

RQ B:8:2 A:4:4 D:1:1 Proc in CPU: Q: 3:0


: expires
p p p

60
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:4 4 4:4
B 2 8:0 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:1 1 1:1

RQ A:4:4 D:1:1 Proc in CPU: Q: 3:0


: expires
p p p

61
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:3 4 4:4
B 2 8:0 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:1 1 1:1

RQ D:1:1 B:8:8 Proc in CPU: A:4:3 Q: 3:1


: expires
p p p

62
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:1 4 4:4
B 2 8:0 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:1 1 1:1

RQ D:1:1 B:8:8 A:4:1 Proc in CPU: A:4:1 Q: 3:3


:
preemption expires
p p p p

63
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:1 4 4:4
B 2 8:0 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:1

RQ B:8:8 A:4:1 Proc in CPU: Q: 3:0


: expires
p p p p

64
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:1 4 4:4
B 2 8:0 1 8:7 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:1

RQ A:4:1 D:1:1 Proc in CPU: B:8:7 Q: 3:1


: expires
p p p p

65
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:1 4 4:4
B 2 8:0 1 8:5 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:1

RQ A:4:1 D:1:1 B:8:5 Proc in CPU: B:8:5 Q: 3:3


:
preemption expires
p p p p p

66
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:0 4 4:4
B 2 8:0 1 8:5 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:1

RQ D:1:1 B:8:5 Proc in CPU: Q: 3:0


: expires
p p p p p

67
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:0 4 4:4
B 2 8:0 1 8:5 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:0

RQ B:8:5 Proc in CPU: Q: 3:0


: expires
p p p p p

68
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:0 4 4:4
B 2 8:0 1 8:2 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:0

RQ A:4:4 B:8:2 Proc in CPU: B:8:2 Q: 3:0


:
preemption expires
p p p p p p

69
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:0 4 4:1
B 2 8:0 1 8:2 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:0

RQ B:8:2 A:4:1 Proc in CPU: A:4:1 Q: 3:3


:
preemption expires
p p p p p p p

70
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:0 4 4:1
B 2 8:0 1 8:0 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:0

RQ A:4:1 Proc in CPU: Q: 3:0


: expires
p p p p p p p

71
Algorithme du Tourniquet (Round Robin)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:0 4 4:0
B 2 8:0 1 8:0 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:0

RQ Proc in CPU: Q: 3:0


: expires
p p p p p p p

72
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Processor utilization = (35 / 35) * 100 = 100 %


• Throughput = 4 / 35

73
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Turn around time:


tatA = 35 – 0 = 35
tatB = 34 – 2 = 32
tatC = 15 – 3 =12
tatD = 26 – 7 = 19

tatAVG = (35 + 32 + 12 + 19) / 4 = 24.

74
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• *

• Turn around time:


tatA = 35 – 0 = 35
tatB = 34 – 2 = 32
tatC = 15 – 3 =12
tatD = 26 – 7 = 19

tatAVG = (35 + 32 + 12 + 19) / 4 = 24.

75
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Turn around time:


tatA = 35 – 0 = 35
tatB = 34 – 2 = 32
tatC = 15 – 3 =12
tatD = 26 – 7 = 19

tatAVG = (35 + 32 + 12 + 19) / 4 = 24.

76
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Turn around time:


tatA = 35 – 0 = 35
tatB = 34 – 2 = 32
tatC = 15 – 3 =12
tatD = 26 – 7 = 19

tatAVG = (35 + 32 + 12 + 19) / 4 = 24.

77
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Turn around time:


tatA = 35 – 0 = 35
tatB = 34 – 2 = 32
tatC = 15 – 3 =12
tatD = 26 – 7 = 19

tatAVG = (35 + 32 + 12 + 19) / 4 = 24

78
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Waiting time:
wtA = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15
wtB = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15
wtC = (6 – 3) + (13 – 9) = 7
wtD = (12 – 7) + (20 – 14) + (25 – 22) = 14

wtAVG = (15 + 12 + 7 + 11) / 4 = 11.25

79
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Waiting time:
wtA = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15
wtB = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15
wtC = (6 – 3) + (13 – 9) = 7
wtD = (12 – 7) + (20 – 14) + (25 – 22) = 14

wtAVG = (15 + 12 + 7 + 11) / 4 = 11.25

80
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Waiting time:
wtA = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15
wtB = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15
wtC = (6 – 3) + (13 – 9) = 7
wtD = (12 – 7) + (20 – 14) + (25 – 22) = 14

wtAVG = (15 + 12 + 7 + 11) / 4 = 11.25

81
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Waiting time:
wtA = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15
wtB = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15
wtC = (6 – 3) + (13 – 9) = 7
wtD = (12 – 7) + (20 – 14) + (25 – 22) = 14

wtAVG = (15 + 12 + 7 + 11) / 4 = 11.25

82
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Waiting time:
wtA = (0 – 0)+(8 – 3)+(17 – 13)+(24 – 20)+(29 – 29)+(34 – 32)=15
wtB = (3 – 2)+(9 – 6)+ (15 -12)+(21 – 18)+(26 – 24)+(32 – 29) =15
wtC = (6 – 3) + (13 – 9) = 7
wtD = (12 – 7) + (20 – 14) + (25 – 22) = 14

wtAVG = (15 + 14 + 7 + 11) / 4 = 12.75

83
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Response time:
rtA = 0 – 0 = 0
rtB = 36 – 2 = 1
rtC = 6 – 3 = 3
rtD = 12 – 7 = 5

rtAVG = (0 + 1 + 3 + 5) / 4 = 2.25

84
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Response time:
rtA = 0 – 0 = 0
rtB = 3 – 2 = 1
rtC = 6 – 3 = 3
rtD = 12 – 7 = 5

rtAVG = (0 + 1 + 3 + 5) / 4 = 2.25

85
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Response time:
rtA = 0 – 0 = 0
rtB = 36 – 2 = 1
rtC = 6 – 3 = 3
rtD = 12 – 7 = 5

rtAVG = (0 + 1 + 3 + 5) / 4 = 2.25

86
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Response time:
rtA = 0 – 0 = 0
rtB = 3 – 2 = 1
rtC = 6 – 3 = 3
rtD = 12 – 7 = 5

rtAVG = (0 + 1 + 3 + 5) / 4 = 2.25

87
Algorithme du Tourniquet (Round Robin)

p p p p p p p

• Response time:
rtA = 0 – 0 = 0
rtB = 3 – 2 = 1
rtC = 6 – 3 = 3
rtD = 12 – 7 = 5

rtAVG = (0 + 1 + 3 + 5) / 4 = 2.25

88
PLUS COURT TEMPS D’UTILISATION
D’ABORD PRÉEMPTIF

Nadia Bel Hadj Aissa 89


2.3.3 Shortest-Remaining-Time-First (SRTF)

preemption

START READY RUNNING HALTED

I/O I/O
completed requested
WAITING

Start : Le procesus vient d’être créé.


Ready : Le processus attend d’obtenir le processeur.
Running : Le processus a été alloué par le processeur.
Waiting : Le processeur est entré en E/S ou bloqué.
Halted : Le processus a fini et va quitter le système
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:4 4 4:4 4 4:4
B 2 8:8 1 8:8 - -
C 3 2:2 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

SRTF RQ A:4:4 Proc in CPU:


: next_cpu_burst : remaining_time

FCFS
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:2 4 4:4 4 4:4
B 2 8:8 1 8:8 - -
C 3 2:2 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RQ B:8:8 Proc in CPU: A:4:2


: next_cpu_burst : remaining_time continue
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:1 4 4:4 4 4:4
B 2 8:8 1 8:8 - -
C 3 2:2 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RQ B:8:8 C:2:2 Proc in CPU: A:4:1


:
continue
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:4 4 4:4
B 2 8:8 1 8:8 - -
C 3 2:2 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RQ B:8:8 C:2:2 Proc in CPU:


:
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:4 4 4:4
B 2 8:8 1 8:8 - -
C 3 2:0 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RQ B:8:8 Proc in CPU:


:
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:4 4 4:4
B 2 8:7 1 8:8 - -
C 3 2:0 1 2:2 - -
D 7 1:1 1 1:1 1 1:1

RQ D:1:1 B:8:7 Proc in CPU: B:8:7


:
preemption
p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:4 4 4:4
B 2 8:7 1 8:8 - -
C 3 2:0 1 2:2 - -
D 7 1:0 1 1:1 1 1:1

RQ B:8:7 A:4:4 Proc in CPU:


:

p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:3 4 4:4
B 2 8:7 1 8:8 - -
C 3 2:0 1 2:2 - -
D 7 1:0 1 1:1 1 1:1

RQ B:8:7 C:2:2 A:4:3 Proc in CPU: A:4:3


:
preemption
p p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:3 4 4:4
B 2 8:7 1 8:8 - -
C 3 2:0 1 2:1 - -
D 7 1:0 1 1:1 1 1:1

RQ B:8:7 A:4:3 D:1:1 Proc in CPU: C:2:1


:
continues
p p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:3 4 4:4
B 2 8:7 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:1 1 1:1

RQ B:8:7 A:4:3 D:1:1 Proc in CPU:


:
continues
p p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:3 4 4:4
B 2 8:7 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:1

RQ B:8:7 A:4:3 Proc in CPU:


:
continues
p p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:2 4 4:4
B 2 8:7 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:1

RQ B:8:7 D:4:1 A:4:2 Proc in CPU: A:4:2


:
preemption continues
p p p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:2 4 4:4
B 2 8:7 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:0

RQ B:8:7 A:4:2 Proc in CPU:


:
continues
p p p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:0 4 4:4
B 2 8:7 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:0

RQ B:8:7 Proc in CPU:


:
continues
p p p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:0 4 4:4
B 2 8:3 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:0

RQ A:4:4 Proc in CPU: B:8:3


:
continues
p p p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:0 4 4:4
B 2 8:0 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:0

RQ A:4:4 Proc in CPU:


:
continues
p p p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:0 4 4:3
B 2 8:0 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:0

RQ B:8:8 Proc in CPU: A:4:3


:
continues
p p p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:0 4 4:0
B 2 8:0 1 8:8 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:0

RQ B:8:8 Proc in CPU:


:
continues
p p p
2.3.3 Shortest-Remaining-Time-First (SRTF)

Process Arrival 1st exec 1st I/O 2nd exec 2nd I/O 3rd exec
time
A 0 4:0 4 4:0 4 4:0
B 2 8:0 1 8:0 - -
C 3 2:0 1 2:0 - -
D 7 1:0 1 1:0 1 1:0

RQ Proc in CPU:
:
continues
p p p
2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Processor utilization = (35 / 35) * 100 = 100 %


• Throughput = 4 / 35 = 0.11
2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Turn around time:


tatA = 27 – 0 = 27
tatB = 35 – 2 = 33
tatC = 11 – 3 = 8
tatD = 14 – 7 = 7

tatAVG = (27 + 33 + 8 + 7) / 4 = 18.75


2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Turn around time:


tatA = 27 – 0 = 27
tatB = 35 – 2 = 33
tatC = 11 – 3 = 8
tatD = 14 – 7 = 7

tatAVG = (27 + 33 + 8 + 7) / 4 = 18.75


2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Turn around time:


tatA = 27 – 0 = 27
tatB = 35 – 2 = 33
tatC = 11 – 3 = 8
tatD = 14 – 7 = 7

tatAVG = (27 + 33 + 8 + 7) / 4 = 18.75


2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Turn around time:


tatA = 27 – 0 = 27
tatB = 35 – 2 = 33
tatC = 11 – 3 = 8
tatD = 14 – 7 = 7

tatAVG = (27 + 33 + 8 + 7) / 4 = 18.75


2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Turn around time:


tatA = 27 – 0 = 27
tatB = 35 – 2 = 33
tatC = 11 – 3 = 8
tatD = 14 – 7 = 7

tatAVG = (27 + 33 + 8 + 7) / 4 = 18.75


2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Waiting time:
wtA = (0 – 0) + (8 – 8) + (12 - 9) + (14 – 13) + (23 - 20) = 7
wtB = (6 – 2) + (16 – 7) + (27-24) = 16
wtC = (4 – 3) + (9 – 9) = 1
wtD = (7 – 7) + (11 – 10) + (13 – 13) = 1

wtAVG = (7 + 16 + 1 + 1) / 4 = 6.25
2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Waiting time:
wtA = (0 – 0) + (8 – 8) + (12 - 9) + (14 – 13) + (23 - 20) = 7
wtB = (6 – 2) + (16 – 7) + (27-24) = 16
wtC = (4 – 3) + (9 – 9) = 1
wtD = (7 – 7) + (11 – 10) + (13 – 13) = 1

wtAVG = (7 + 16 + 1 + 1) / 4 = 6.25
2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Waiting time:
wtA = (0 – 0) + (8 – 8) + (12 - 9) + (14 – 13) + (23 - 20) = 7
wtB = (6 – 2) + (16 – 7) + (27-24) = 16
wtC = (4 – 3) + (9 – 9) = 1
wtD = (7 – 7) + (11 – 10) + (13 – 13) = 1

wtAVG = (7 + 16 + 1 + 1) / 4 = 6.25
2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Waiting time:
wtA = (0 – 0) + (8 – 8) + (12 - 9) + (14 – 13) + (23 - 20) = 7
wtB = (6 – 2) + (16 – 7) + (27-24) = 16
wtC = (4 – 3) + (9 – 9) = 1
wtD = (7 – 7) + (11 – 10) + (13 – 13) = 1

wtAVG = (7 + 16 + 1 + 1) / 4 = 6.25
2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Waiting time:
wtA = (0 – 0) + (8 – 8) + (12 - 9) + (14 – 13) + (23 - 20) = 7
wtB = (6 – 2) + (16 – 7) + (27-24) = 16
wtC = (4 – 3) + (9 – 9) = 1
wtD = (7 – 7) + (11 – 10) + (13 – 13) = 1

wtAVG = (7 + 16 + 1 + 1) / 4 = 6.25
2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Response time:
rtA = 0 – 0 = 0
rtB = 6 – 2 = 4
rtC = 4 – 3 = 1
rtD = 7 – 7 = 0

rtAVG = (0 + 4 + 1 + 0) / 4 = 1.25
2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Response time:
rtA = 0 – 0 = 0
rtB = 6 – 2 = 4
rtC = 4 – 3 = 1
rtD = 7 – 7 = 0

rtAVG = (0 + 4 + 1 + 0) / 4 = 1.25
2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Response time:
rtA = 0 – 0 = 0
rtB = 6 – 2 = 4
rtC = 4 – 3 = 1
rtD = 7 – 7 = 0

rtAVG = (0 + 4 + 1 + 0) / 4 = 1.25
2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Response time:
rtA = 0 – 0 = 0
rtB = 6 – 2 = 4
rtC = 4 – 3 = 1
rtD = 7 – 7 = 0

rtAVG = (0 + 4 + 1 + 0) / 4 = 1.25
2.3.3 Shortest-Remaining-Time-First (SRTF)

p p p

• Response time:
rtA = 0 – 0 = 0
rtB = 6 – 2 = 4
rtC = 4 – 3 = 1
rtD = 7 – 7 = 0

rtAVG = (0 + 4 + 1 + 0) / 4 = 1.25
COMPARAISON

Nadia Bel Hadj Aissa 126


Tableau récapitulatif

FCFS SJF PSJF Tourniquet


tatavg 28.25 23.50 18.75 24.50
wtavg 16.50 10.50 6.25 12.25
rtavg 4.50 3.00 1.25 2.25
Facile à Impossible de Impossible de Implémentable,
implémenter connaitre le connaitre le rtmax est
prochain temps prochain important pour
de travail du temps de les systèmes
CPU travail du CPU interactifs
exacement. exacement.

127

Vous aimerez peut-être aussi