Anda di halaman 1dari 5

Shortest Job Next arbitration algorithm

Shortest Job Next (SJN) is non-preemptive algorithm. It gives advantages to process that is present in
the queue and has shortest serving time.
In our example (Fig.1) you see five processes.
At 0 tick process A comes to the system. It is the single pretender to use processor resource, and at the
0 tick process A become active and will use 6 processor ticks for serving..
At the 2-nd tick process B (with needed serving time equal 3) comes to the system. Process A is
active, therefore process B enters the queue.
At the 3-d tick process C (with needed serving time equal 7) comes to the system. Process A is active,
therefore process C enters the queue after process B.
At the 6-tick process A was served and it leaves the system. System manager must decide which
process will be activated next. There are two pretenders in the queue process B and process C.
Process B has less serving time than C has that is why process B become active.
At the 16-th tick process C is served. Queue contains two processes D (with serving time 7) and E
(serving time 4). System manager activates process E because it has smaller serving time. Process D
continues idle until process C will be finished.

Fig.1

Shortest Job Next arbitration algorithm

A(6)
D(7)

. . . . . . . . . . . . . . . . . .

. . . . . . .

. B(3) . . . . . E(4) . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . C(7) . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . .

>
0
5
10
15
20
25


AAAAAABBBCCCCCCCEEEEDDDDDDD

Selfish Round Robin arbitration algorithm


Selfish Round Robin (SRR) is preemptive algorithm. It gives additional advantages to processes that
were running but not yet finished. This method allows to increase processor capability. All processes
are divided into two groups: new processes and chosen processes. New processes never had before
processor time slice (the quantity of processor ticks defined in the system), rest processes belong to
the chosen group. Each new process when coming to the system has a priority P0, it is the same for
all new processes, and this priority further grows. When each processor time quantum is over,
priorities of all processes are recalculated. Priority of new processes are increasing by dA rate,
priority of chosen processes are increasing by dB rate.
The CPU chooses and serves the process with highest priority rating, when equal ratings CPU is given
to the first process in the queue.
Strategy indexes depend very much on correlation between dA and dB rates. If dA/dB = 0 SRR
strategy become trivial RR. If dA/dB = 1 SRR strategy become FCFS.
The example of SRR using is shown in Fig.2. In this case are used parameters:
P0 = 0; dA = 2; dB = 1; Q = 1.

Fig.2

SRR arbitration algorithm

A(6) E(4)

. . .

. B(3) D(6) . . .

. . . . . . .

. . . .

. . . C(7) . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . .

time. . . . . . . . . . . . . . . . . . . . . . . . .

>
0
5
10
15.
20
25

priorities

A 1 2 3 4 5 6 7 8 9 10

B 0 2 3 4 5 6 7

C
0 2 4 6 7 8 9 1011121314

D
0 2 4 6 8 10111213141516171819

E
0 2 4 6 8 10121416171819


AABABACBACACCCCDDDDEDEDEEE

Under time scale are shown current values of priorities for each process. Process A when coming into
the system has 0 priority because it has category new. No processes are present in the system except

process A, therefore process A become active and uses processor resource. Using even one processor
time quantum, process A receives category chosen. Therefore, when given processor time slice is
over (in Fig.2, tick 1), processs A priority is 1 (it will be increased by dB=1).
At the tick 1 process B appears in the system (Fig.2) and it has 0 priority. At the tick 1 processor is
given to process A again because priority of process A is 2 that is greater than priority of process B,
equal 0.
At the end of the second tick process B has priority equal 2 because it does not use any processor time
slice and belongs to the new group. This time process A has priority equal 2. Priority of A and B
processes are equal but processor is given to process B because it has waited during more long time
than A. From this moment, process B become chosen and until it will live the system it will have
priority grows equal dB.
New process C comes to the system at the 3-d tick. Process C will wait during 3 ticks until its
priority become equal to priorities of chosen processes A and B.
At the 6-th tick there are 3 processes present in the system A, B, C. All named processes have
priority equal 6. The system manager decides to give next processor time slice to process C because it
belongs to new group. After using time slice process C passes to the group chosen. After that
priority of process C will be increased by dB=1.
At the 7-th tick system manager decides to give next processor time slice to process B because it is
first in the queue.
In the similar manner rest processes will be served by processor.

Objective
1. Using SJN arbitration algorithm try to build diagram of processor switching between
processes that are present in the system. Information about processes is given in the table 1
(see next page).
2. Using SRR arbitration algorithm try to build diagrams of processor switching between
processes that are present in the system. Information about processes is given in table 1.
3. Make calculations, like shown in table 1 (given in lab1) for each given algorithm.
4. Compare your results (figures and calculations) with figures and calculations made by
programming application Process.
5. Form task for 3 long and 5 short processes. Using programming application Process
simulate processor switching for serving formed processes. Compare calculated indexes
for short and long processes. Make conclusions about justice of serving for long and short
processes.
6. Show teacher your results.
7. Compare productivity of your computer system in each case. Make conclusions.
8. Make report about the work you had done.

Report must contain


1.
2.
3.
4.

Purpose of the work


Task
Instructions to the task (explanations of proposed algorithms)
Execution of the task
Figures
Calculations
5. Conclusions

Table 1 Tasks for Lab#2

1
2
3
4
5
6
7
8
9
10
11
12

A(8)-0; B(7)-5; C(3)-2; D(8)-1; E(3)-4


A(9)-0; B(2)-2; C(5)-4; D(6)-1; E(5)-3
A(7)-0; B(7)-1; C(3)-2; D(4)-4; E(6)-5
A(9)-0; B(5)-3; C(6)-4; D(2)-1; E(6)-2
A(9)-5; B(5)-3; C(6)-4; D(2)-1; E(6)-0
A(8)-1; B(2)-3; C(6)-4; D(7)-0; E(6)-2
A(8)-3; B(4)-1; C(6)-0; D(3)-2; E(5)-4
A(10)-1; B(4)-2; C(6)-3; D(3)-4; E(5)-6
A(10)-2; B(4)-3; C(6)-0; D(3)-1; E(5)-5
A(7)-4; B(4)-5; C(6)-0; D(3)-2; E(5)-1
A(3)-6; B(7)-2; C(5)-3; D(10)-0; E(4)-4
A(11)-0; B(8)-2; C(5)-5; D(4)-1; E(6)-3

SJN; SRR (Q=1; Q=2)


P0 dA dB
0
2
1 13 A(10)-3; B(3)-1; C(6)-0; D(3)-2; E(5)-4
1
3
2 14 A(10)-1; B(3)-2; C(6)-3; D(3)-4; E(5)-6
0
2
1 15 A(7)-2; B(4)-3; C(9)-0; D(3)-1; E(5)-5
1
3
1 16 A(7)-4; B(4)-5; C(11)-0; D(3)-2; E(3)-1
0
2
1 17 A(3)-6; B(4)-2; C(5)-3; D(10)-0; E(4)-4
1
3
2 18 A(11)-0; B(8)-2; C(5)-5; D(4)-1; E(6)-3
0
2
1 19 A(10)-0; B(7)-5; C(5)-2; D(8)-1; E(3)-4
1
3
1 20 A(9)-0; B(6)-2; C(5)-4; D(6)-1; E(5)-3
0
2
1 21 A(11)-0; B(7)-1; C(5)-2; D(4)-4; E(6)-5
1
3
2 22 A(10)-0; B(5)-3; C(6)-4; D(7)-1; E(6)-2
0
2
1 23 A(6)-5; B(5)-3; C(6)-4; D(7)-1; E(10)-0
1
3
1 24 A(3)-1; B(5)-3; C(6)-4; D(11)-0; E(6)-2

P0 dA dB
0
2
1
1
3
2
0
2
1
1
3
1
0
2
1
1
3
2
0
2
1
1
3
1
0
2
1
1
3
2
0
2
1
1
3
1

Anda mungkin juga menyukai