Вы находитесь на странице: 1из 3

HOMEWORK PS05

Problem 1
a) As given, the highest exponential effect priority is pvmax. As seen from the slides, the length of
the major cycle is basically the number of minor cycles. So the length of the major cycle is
2 pvmax .
b) The algorithm given in the slides shows two arrays used in the algorithm. One array is used for
storing the wait values for each process. So this array will have k-values. The second array used
is the priorities array pv which again has a size of k. Therefore, we will require 2k memory
fields.

Problem 2
a) In binary, 6 = 110
So now, Reverse(6,3) = < 0 1 1 > = 3
b) In binary, 6 = 110
So now, Reverse (6 , 4) = < 0 1 1 0 > = 6
c) In binary, 13 = 1101
So now, Reverse (13,5) = < 0 1 1 0 1 > = 22

Problem 3
The pseudocode is written below using C math library functions for power as well:
fun REVERSE (X, i) {
If ( i > 8 ) or ( i < 1 ) then
Give an error
if ( i == 1 ) then return X
else
Y = REVERSE(RLS(X), i - 1)
return Y + ( X MOD 2) * pow (2, i -1)
}
Basically, my function implements the REVERSE function on 8 bits. This means that the largest bit is
at position 7 so the biggest power in binary is 27 .
This gives us of exponential priorities from 0 to 7.
If 1024 Hz corresponds to priority 0 then, for priority 1 we have 1024 * 21 = 512 Hz
Hence, for priority 7, we get 1024 * 27 = 8 Hz.
So the slowest frequency on which the highest priority processes run is 8 Hz.

Problem 4
Here, we will use the waiting part of the B-scheduling algorithm. Using the table, we will have maxpv
= 4 in this case. There are a variable number of processes in each priority.
Initially, pc = 1, start = 0 and n slots=1
So for pv = 1:
Pc = 1, start = 0 and n slots=2
Wait[p1.1] = REVERSE((0 + 1) % 2, 1) = 1
Wait[p1.2] = REVERSE((0 + 2) % 2, 1) = 0
Wait[p1.3] = REVERSE((0 + 3) % 2, 1) = 1
Now, pc = 2, start = 1 and n slots=2
Now, for pv = 2:
pc = 2, start = 2 and n slots=22=4
Wait[p2.1] = REVERSE((2 + 1) % 4, 2) = 3
Wait[p2.2] = REVERSE((2 + 2) % 4, 2) = 0
pc = 3, start = 0 and n slots=4
Now, for pv = 3:
pc = 3, start = 0 and n slots=42=8
Wait[p3.1] = REVERSE((0 + 1) % 8, 3) = 4
pc = 4, start = 1 and n slots=8
Now, for pv = 4:
pc = 4, start = 2 and n slots=82=16
Wait[p4.1] = REVERSE((2 + 1) % 16, 4) = 12
Wait[p4.2] = REVERSE((2 + 2) % 16, 2) = 2
(The wait values are in bold)

Problem 5
For assigning the priorities, we know that the priority value increases with an increase in the time
period. This is shown as follows in the table below:
Name
P0
P1
P2
P3
P4
Ti
Period
(msec)
C i (msec)
Priority

100

30

80

30

25

10
1

5
2

8
3

10
4

1
5

To check if a schedule exsits, the following equation for utilization must be satisfied:
1
n

U U rms=n(2 1)
When n = 5,

We get U =5 2 5 1 =0.7435
rms

Now, calculating the utilization, we get


10 5 8 10 1
U=
+ + + + =0.74
100 30 30 30 25
Since, 0.74 < 0.7435, we can be certain that processes can be scheduled.
The diagram for showing these processes in sequence is shown in the next page:
A key feature of the diagram is an interval till 100 msec is cover to show all 5 processes in action on
the diagram. After 100 msec, the diagram will of course continue to give a similar execution of

processes according to their priorities as shown in the diagram as well.

Вам также может понравиться