-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuunifast.py
53 lines (43 loc) · 1.61 KB
/
uunifast.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Hosein Kangavar Nazari - CS student, IASBS university
# RealTime course first assinment's Code
# UUnifast for making different task sets
import random
from task import task, generateTaskFromUtilization, writeTaskSetToFile
def uunifast(n, U):
vectU = []
sumU = U
for i in range(1, n):
nextSumU = sumU * (random.uniform(0, 1)**(1/(n-i)))
vectU.append(sumU-nextSumU)
sumU = nextSumU
vectU.append(sumU)
AllSum = 0
#summation over all utilization for finding global utilization
for i in range(len(vectU)):
AllSum += vectU[i]
return AllSum, vectU
def uunifasts(N, n, U):
# if there is a file at the moment, overwrite on it
file = open("Task_List.txt", "w")
# will be used for configuration propose
configuration_data = str(N) + " " + str(n)
file.write(configuration_data)
file.write("\n")
counter = 1
while(counter <= N):
Sum, Vect = uunifast(n, U)
# Because of rounding errors, utilization may not be same as given U
# for example, 0.9999 is unacceptable when utilization(U) is equal to 1
if(Sum == U):
# call function that makes the
taskSet = generateTaskFromUtilization(Vect)
#counters seperates outputs of each runs
writeTaskSetToFile(counter, taskSet, file)
counter += 1
file.close()
# run 1000 time , make 100 job in each list and with 1 utilization
# set proper values here
RUN = 10 # how many times we run unifast algorithm
JOB_NUMBERS = 6 #task number in each list
UTILIZATION = 1 #Utilization
uunifasts(RUN, JOB_NUMBERS, UTILIZATION)