You are on page 1of 6

Exercise Sheet No.

3 SOLUTIONS

Exercise 1 :
Processus Date d’arrivé Date en unités Temps Priorité
d’exécution
P1 19h47m 0 7m 4
P2 19h47m 0 8m 2
P3 19h53m 6 4m 3
P4 19h58m 11 6m 1
P5 20h 13 2m 5

1) SJF :

Average waiting time = ( 0 + 19 + 1 + 0 + 4 ) / 5 = 4.8 m

2) Priority Scheduling :

Average waiting time = (0+11+1+10+6)/5= 5.6 m

3) SRTF :

5) Round Robin with a time quantum equal to 5 minutes:

Explanation: The queue of ready processes will evolve as follows:


Average waiting time : (5 + 11 + 6 + 10 + 11) /5 = 8,6m

6) RR with a time quantum equal to 8 min. Considering that the time required for a process
switch is 3 min:

The context switch (CS): allows the transition from the execution of one process to another.
It involves saving the context of the stopped process and loading the context of the new
process. In our case, a context switch (CS) requires 3 min. The Gantt chart will be as follows:

Number of context switches: 5


Average waiting time : (3 + 13 + 18 + 20 + 27) /5 = 16.2 m

Exercise 02 :

Q1 :

Q2 :
The content of the ready process queue at time t=10: At time t=10, process P1 finishes its
execution, P2 occupies the CPU, so the queue consists of two processes, P3 and P4 (ordered
by priority, P3 then P4).

Q3 : Definition of waiting time: It is the time a process spends in the queue of ready
processes.
Q4 : Definition of turnaround time: It is the time that elapses between the submission of a
process (its creation) and its termination.

Q5 :

Process Waiting time Turnaround time


P1 0 10
P2 17 21
P3 21 28
P4 25 29
P5 0 10

Q6 :
At t=19, P5 requests an I/O operation, while P2 occupies the processor.
At t=22, the I/O operation is completed, and P5 occupies the processor.

Q7 :

Process Waiting time Turnaround time


P1 0 10
P2 17 23
P3 23 30
P4 27 31
P5 0 15

Exercise 03 :
Gantt chart

Process Response time Waiting time Turnaround time


P1 0 0+3+4=7 13
P2 2 2+2=4 3+5 = 8
P3 3 3+4+4+1=12 20
P4 4 4+2=6 6+3=9
P5 4 4 6
Exercise 04 :
Q1. Yes, the scheduling algorithm could be Round Robin, as both processes appear to share
the processor in alternation with a quantum that would be equal to 2.
Q2. At time t=9, an event has interrupted the execution of the quantum assigned to process
P1: This could be waiting for an I/O operation or waiting for a signal.
Q3. Yes, the scheduling algorithm could also be FCFS: after obtaining the processor,
processes P1 and P2 consistently request I/O after 2 time units.
Q4.

Process Response time Waiting time Turnaround time


P1 0 16 ND
P2 2 14 ND

The waiting time, which is equal to the time spent by the process in the ready queue, is
undetermined (ND): We cannot accurately determine this time for both the Round Robin and
FCFS algorithms because in both cases there is an I/O operation or waiting for a signal
whose duration is unknown.

Exercise 05 :

Q1.

Q2.

Q3.

Process Response time Waiting time Turnaround time


P1 0 4 13
P2 2 7 16
P3 3 6 26
P4 5 7 11
Exercise 06 :
Q1. FCFS

Priority Scheduling:

Round Robin Scheduling Algorithm:

Q2.

FCFS :

Priority Scheduling:

Round Robin Scheduling Algorithm:

Exercise 07 :
Q1.

By moving a process to a lower priority queue after granting it a maximum execution time on
a queue, this method prevents the processor from being monopolized by a long process.
Q2.

Q3.

Process Response time Waiting time Turnaround time


P1 0 44 60
P2 8 42 56
P3 16 38 48
P4 24 46 66
P5 32 32 38

Exercise 08 :
Q1. Multilevel scheduling adapts well to situations where the processes to be scheduled do
not have the same profile: they are not of the same type (for example: system processes, user
processes, batch processes, etc.) and therefore need to be scheduled differently.
Q2. File1 is the least priority, a process from this file can occupy the processor only if File2
and File3 are empty.
Q3. A process can have a waiting time equal to 0 in three cases: The process is of type 3:
File3 is empty when this process arrives. The process is of type 2: File3 is empty, File2 is
empty when this process arrives. The process is of type 1: File3 is empty, File2 is empty,
File1 is empty when this process arrives.
Q4.

Q5.

Process Response time Waiting time Turnaround time


A 11 11 14
B 13 13 17
C 0 06 11
D 0 0 02
E 01 01 05

You might also like