-
Notifications
You must be signed in to change notification settings - Fork 0
/
rts.py
executable file
·198 lines (162 loc) · 5.67 KB
/
rts.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/usr/bin/env python
import pandas as pd
from argparse import ArgumentParser
from rts.Helpers import *
from rts.Processor import *
from rts.Task import *
from rts.TaskSet import *
def parse_args():
# Parse Arguments
parser = ArgumentParser()
parser.add_argument("--uni", "-u", help="Perform uniprocessor scheduling tests", action="store_true")
parser.add_argument("--mpart", "-p", help="Perform partitioning multiprocessor scheduling tests", action="store_true")
parser.add_argument("--mglob", "-g", help="Perform global multiprocessor scheduling tests", action="store_true")
return parser.parse_args()
def main():
args = parse_args()
T = TaskSet(PTask(7, 2), PTask(21, 3), PTask(29, 9), PTask(49,15), PTask(64, 20), PTask(66, 16), PTask(160, 32), PTask(235, 72), PTask(260, 25), PTask(450, 120))
CPU = Processor(4)
line = '\n' + '-' * 50 + '\n'
sline = '-' * 50
def test(r): return f"Test success: {r}"
def stest(r, proc="pessimistic"): return ("Result: Task set is schedulable" if r else "Result: Task set is not schedulable") + " (" + proc + ")"
print(f"\nResults for Task Set: {T}\n")
if not args.uni and not args.mpart and not args.mglob:
print("No category selected. Use --uni, --mpart or --mglob to select a category.\n")
exit(0)
if args.uni:
print(sline)
print("UP Scheduling Tests")
print(sline)
print('\n')
isp = T.is_simple_periodic()
print(f"Task Set is simple periodic: {isp}")
print(line)
if isp:
print("[RMS] u < 1 Test")
ult1t = T.ult1_test()
print(stest(ult1t, "optimistic"))
print(line)
print("[RMS] Liu-Layland-Test")
llt = T.ll_test()
print(stest(llt))
print(line)
print("[RMS] RMA Test")
rmat = T.rma_test()
print(stest(rmat, "optimistic"))
print(line)
print("[RMS] Hyperbolic Bound")
hb = T.hyperbolic_bound()
print(stest(hb))
print(line)
print("[RMS] Burchard Test")
bt = T.burchard_test()
print(stest(bt))
print(line)
print("[RMS] SR-Test")
srt_df = pd.DataFrame(T.sr_test()).T
success = len(np.where(srt_df["u < 1"].isin(["True", True]))[0]) > 0
print(srt_df)
print(stest(success))
print(line)
print("[EDF] u < 1 Test")
ult1t = T.ult1_test()
print(stest(ult1t, "optimistic"))
print('\n')
if args.mpart:
print(sline)
print("MP Partitioning Procedures")
print(sline)
print('\n')
print("RM Next Fit")
rmnft = CPU.rmnf(T)
rmnf_df = pd.DataFrame(CPU.get_partitioning()).T
print(rmnf_df)
print(f"Average Core Utilization: {round(np.mean(rmnf_df['u_rel']), 4) * 100}%")
print(test(rmnft))
print(line)
print("RM First Fit")
rmfft = CPU.rmff(T)
rmff_df = pd.DataFrame(CPU.get_partitioning()).T
print(rmff_df)
print(f"Average Core Utilization: {round(np.mean(rmff_df['u_rel']), 4) * 100}%")
print(test(rmfft))
print(line)
print("RM First Fit with Decreasing Utilization")
rmffdut = CPU.rmffdu(T)
rmffdu_df = pd.DataFrame(CPU.get_partitioning()).T
print(rmffdu_df)
print(f"Average Core Utilization: {round(np.mean(rmffdu_df['u_rel']), 4) * 100}%")
print(test(rmffdut))
print(line)
print("RM Small Task")
rmstt = CPU.rmst(T)
rmst_df = pd.DataFrame(CPU.get_partitioning()).T
print(rmst_df)
print(f"Average Core Utilization: {round(np.mean(rmst_df['u_rel']), 4) * 100}%")
print(test(rmstt))
print(line)
# print("RM General Task")
# rmgtt = CPU.rmgt(T)
# rmgt_df = pd.DataFrame(CPU.get_partitioning()).T
# print(rmgt_df)
# print(test(rmgtt))
# print(line)
# print("RM Best Fit")
# rmbft = CPU.rmbf(T)
# rmbf_df = pd.DataFrame(CPU.get_partitioning()).T
# print(rmbf_df)
# print(test(rmbft))
# print(line)
# print("RM Worst Fit")
# rmwft = CPU.rmwf(T)
# rmwf_df = pd.DataFrame(CPU.get_partitioning()).T
# print(rmwf_df)
# print(test(rmwft))
# print(line)
print("EDF Next Fit")
edfnft = CPU.edfnf(T)
edfnf_df = pd.DataFrame(CPU.get_partitioning()).T
print(edfnf_df)
print(f"Average Core Utilization: {round(np.mean(edfnf_df['u_rel']), 4) * 100}%")
print(test(edfnft))
# print(line)
# print("EDF First Fit")
# edffft = CPU.edfff(T)
# edfff_df = pd.DataFrame(CPU.get_partitioning()).T
# print(edfff_df)
# print(test(edffft))
# print(line)
# print("EDF Best Fit")
# edfbft = CPU.edfbf(T)
# edfbf_df = pd.DataFrame(CPU.get_partitioning()).T
# print(edfbf_df)
# print(test(edfbft))
print('\n')
if args.mglob:
print(sline)
print("MP Global Procedures")
print(sline)
print('\n')
print("Adaptive TkC")
atkct = CPU.adaptive_tkc(T)
print(test(atkct))
print(line)
print("RM Utilization Separation")
rmust = CPU.rmus(T)
print(test(rmust))
print(line)
print("Global EDF")
gedft = CPU.global_edf(T)
print(test(gedft))
print(line)
print("EDF Utilization Separation")
edfust = CPU.edfus(T)
print(test(edfust))
print(line)
print("fpEDF")
fpedft = CPU.fpedf(T)
print(test(fpedft))
print('\n')
if __name__ == "__main__":
main()