forked from nils.hoelscher/RTSA-lab02-SchedTest
initial commit.
This commit is contained in:
commit
e98e7e9cb6
|
@ -0,0 +1,2 @@
|
|||
*/__pycache__/*
|
||||
.vscode/*
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "10Tasks",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${cwd}/SchedTest.py",
|
||||
"args": ["--i", "task_sets/10tasks.txt", "--n", "10"],
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true
|
||||
},
|
||||
{
|
||||
"name": "100Tasks",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${cwd}/SchedTest.py",
|
||||
"args": ["--i", "task_sets/100tasks.txt", "--n", "100"],
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
# RTSA-lab01-SchedulabilityTest
|
||||
In this lab session you will learn how to implement the schedulability tests for:
|
||||
|
||||
* Liu and Layland Bound
|
||||
* Time Demand Analysis
|
||||
* Hyperbolic Bound
|
||||
|
||||
All Tasks are periodic, preemptable, fixed priority Tasks with implicit Deadlines.
|
||||
|
||||
The task sets are defined int the text files in 'task_sets/'.
|
||||
|
||||
## Implementing the Tests
|
||||
|
||||
The tests can be found in 'schedTests/' folder in their corresponding files.
|
||||
The test() functions are called, if the test was successful it should return True, otherwise False. For the TDA test the code for sorting the task set is already included, so the task set is ordered by highest priority first.
|
||||
|
||||
The tasksets are represented by a 2D array, where row i is a Task i and the columns contain period(P_i), Deadline (D_i) and WCET (C_i). This is stated in each file with a large comment and examples are given.
|
||||
|
||||
|
||||
## Runing the Tests
|
||||
|
||||
Make sure you have at least python3, argparse and numpy installed.
|
||||
Argpoarse and Numpy can be installed via pip.
|
||||
|
||||
Use the SchedTest.py Script
|
||||
|
||||
```
|
||||
usage: SchedTest.py [-h] --i I --n N
|
||||
|
||||
A small Scheduling test Framework.
|
||||
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
--i I Path to the file containing task sets.
|
||||
--n N Number of tasks per set.
|
||||
```
|
||||
|
||||
N is always and defaults to 10, for our input files.
|
||||
|
||||
## Setup
|
||||
I guess everyone has a running python setup on his machine.
|
||||
If not follow this [guide](https://code.visualstudio.com/docs/python/python-tutorial).
|
||||
|
||||
But we recommend VS Code, as debug tasks are provided in this repo.
|
||||
Also make sure to install the python and pylance extension in VS Code.
|
|
@ -0,0 +1,83 @@
|
|||
import argparse
|
||||
import numpy as np
|
||||
import schedTests.LiuAndLaylandBound as LLB
|
||||
import schedTests.TimeDemandAnalysis as TDA
|
||||
import schedTests.HyperbolicBound as HB
|
||||
import include.TasksHelper as TH
|
||||
# This function Parses the Input Arguments
|
||||
|
||||
|
||||
def parse_args():
|
||||
# Instantiate the parser
|
||||
parser = argparse.ArgumentParser(
|
||||
description='A small Scheduling test Framework.')
|
||||
|
||||
# Required argument
|
||||
parser.add_argument('--i', type=str, required=True,
|
||||
help='Path to the file containing task sets.')
|
||||
# Required argument
|
||||
parser.add_argument('--n', type=int, required=False, default=10,
|
||||
help='Number of tasks per set.')
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
# Read Tasksets in to numpy array from text files
|
||||
|
||||
|
||||
def get_tasksets(filename: str, NrSets: int):
|
||||
input = np.genfromtxt(filename, dtype=float, delimiter=",", comments=";")
|
||||
shape = input.shape
|
||||
tasksets = input.reshape(int(shape[0]/NrSets), NrSets, 3)
|
||||
return tasksets
|
||||
|
||||
|
||||
def main():
|
||||
# Parse Arguments
|
||||
args = parse_args()
|
||||
print(args.i)
|
||||
|
||||
# Read Tasksets from txt files
|
||||
tasksets = get_tasksets(args.i, args.n)
|
||||
print("Successfully parsed Task Sets")
|
||||
shape = tasksets.shape
|
||||
print("Nr. of Task Sets: " + str(shape[0]))
|
||||
print("Nr. of Tasks per Set: " + str(shape[1]))
|
||||
|
||||
# Starting the analysis
|
||||
print("Starting Liu and Layland bound analysis!")
|
||||
stubLLB = []
|
||||
for _ in range(shape[0]):
|
||||
stubLLB.append(False)
|
||||
LLBresults = np.array(stubLLB)
|
||||
for i in range(shape[0]):
|
||||
if LLB.test(tasksets[i]):
|
||||
LLBresults[i] = True
|
||||
print("Task Set: " + str(i) +
|
||||
" fulfills necessary the Liu and Layland Bound!")
|
||||
print()
|
||||
|
||||
print("Starting Hyperbolic bound analysis!")
|
||||
stubHB = []
|
||||
for _ in range(shape[0]):
|
||||
stubHB.append(False)
|
||||
HBresults = np.array(stubHB)
|
||||
for i in range(shape[0]):
|
||||
if HB.test(tasksets[i]):
|
||||
HBresults[i] = True
|
||||
print("Task Set: " + str(i) +
|
||||
" fulfills the sufficient Hyperbolic Bound!")
|
||||
print()
|
||||
|
||||
print("Starting Time Demand Analysis!")
|
||||
stubTDA = []
|
||||
for _ in range(shape[0]):
|
||||
stubTDA.append(False)
|
||||
TDAresults = np.array(stubTDA)
|
||||
for i in range(shape[0]):
|
||||
if TDA.test(tasksets[i]) > 0:
|
||||
TDAresults[i] = True
|
||||
print("Task Set: " + str(i) + " is feasible by TDA analysis!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,19 @@
|
|||
import numpy as np
|
||||
|
||||
def getTotalUtilization(tasks, NrTasks):
|
||||
U = 0
|
||||
for i in range(NrTasks):
|
||||
U += tasks[i][2] / tasks[i][1]
|
||||
return U
|
||||
|
||||
def P_i(tasks, i):
|
||||
return tasks[i][0]
|
||||
|
||||
def D_i(tasks, i):
|
||||
return tasks[i][1]
|
||||
|
||||
def C_i(tasks, i):
|
||||
return tasks[i][2]
|
||||
|
||||
def getNumberOfTasks(tasks):
|
||||
return tasks.shape[0]
|
|
@ -0,0 +1,22 @@
|
|||
import numpy as np
|
||||
import include.TasksHelper as TH
|
||||
|
||||
# The tasks is an Array with three columns and n Rows
|
||||
# Each Row represents one Task
|
||||
# The columns hold the Tasks parameters
|
||||
# column 0 is period P,
|
||||
# column 1 is deadline D
|
||||
# column 2 is WCET C
|
||||
# P_i is accessed as: tasks[i][0]
|
||||
# D_i is accessed as: tasks[i][1]
|
||||
# C_i is accessed as: tasks[i][2]
|
||||
# The number of tasks can be accessed as: tasks.shape[0]
|
||||
|
||||
#The sufficient Test for the Hyperbolic bound
|
||||
def test(tasks):
|
||||
|
||||
#####################
|
||||
#YOUR CODE GOES HERE#
|
||||
#####################
|
||||
|
||||
return False
|
|
@ -0,0 +1,22 @@
|
|||
import numpy as np
|
||||
import include.TasksHelper as TH
|
||||
|
||||
# The tasks is an Array with three columns and n Rows
|
||||
# Each Row represents one Task
|
||||
# The columns hold the Tasks parameters
|
||||
# column 0 is period P,
|
||||
# column 1 is deadline D
|
||||
# column 2 is WCET C
|
||||
# P_i is accessed as: tasks[i][0]
|
||||
# D_i is accessed as: tasks[i][1]
|
||||
# C_i is accessed as: tasks[i][2]
|
||||
# The number of tasks can be accessed as: tasks.shape[0]
|
||||
|
||||
#The necessary Test for the Liu and Layland Bound
|
||||
def test(tasks):
|
||||
|
||||
#####################
|
||||
#YOUR CODE GOES HERE#
|
||||
#####################
|
||||
|
||||
return False
|
|
@ -0,0 +1,28 @@
|
|||
import numpy as np
|
||||
import math
|
||||
import include.TasksHelper as TH
|
||||
|
||||
# The tasks is an Array with three columns and n Rows
|
||||
# Each Row represents one Task
|
||||
# The columns hold the Tasks parameters
|
||||
# column 0 is period P,
|
||||
# column 1 is deadline D
|
||||
# column 2 is WCET C
|
||||
# P_i is accessed as: tasks[i][0]
|
||||
# D_i is accessed as: tasks[i][1]
|
||||
# C_i is accessed as: tasks[i][2]
|
||||
# The number of tasks can be accessed as: tasks.shape[0]
|
||||
|
||||
|
||||
#The Time Demand Analysis Test
|
||||
def test(tasks):
|
||||
#Sorting Taskset by Period/Deadline
|
||||
#This makes implementing TDA a lot easier
|
||||
shape = tasks.shape
|
||||
sortedtasks = tasks[tasks[:, 0].argsort()]
|
||||
|
||||
#####################
|
||||
#YOUR CODE GOES HERE#
|
||||
#####################
|
||||
|
||||
return False
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,199 @@
|
|||
6.2504383551,6.2504383551,0.0712695584018
|
||||
91.7301596676,91.7301596676,1.85973864123
|
||||
5.54218170236,5.54218170236,0.368699984512
|
||||
35.365405996,35.365405996,3.61197473745
|
||||
7.80223783742,7.80223783742,0.395892416097
|
||||
65.6532097008,65.6532097008,4.65778060945
|
||||
3.25455707226,3.25455707226,0.0688358070731
|
||||
91.8771630371,91.8771630371,10.1540122581
|
||||
9.84506928434,9.84506928434,0.689891296569
|
||||
82.9195512397,82.9195512397,12.9550003692
|
||||
;
|
||||
6.2504383551,6.2504383551,0.072317640143
|
||||
91.7301596676,91.7301596676,1.8870877389
|
||||
5.54218170236,5.54218170236,0.374122043108
|
||||
35.365405996,35.365405996,3.665092013
|
||||
7.80223783742,7.80223783742,0.401714363393
|
||||
65.6532097008,65.6532097008,4.72627738312
|
||||
3.25455707226,3.25455707226,0.0698480983536
|
||||
91.8771630371,91.8771630371,10.3033359678
|
||||
9.84506928434,9.84506928434,0.700036756813
|
||||
82.9195512397,82.9195512397,13.1455150805
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0733657218842
|
||||
91.7301596676,91.7301596676,1.91443683656
|
||||
5.54218170236,5.54218170236,0.379544101704
|
||||
35.365405996,35.365405996,3.71820928856
|
||||
7.80223783742,7.80223783742,0.407536310688
|
||||
65.6532097008,65.6532097008,4.79477415679
|
||||
3.25455707226,3.25455707226,0.0708603896341
|
||||
91.8771630371,91.8771630371,10.4526596774
|
||||
9.84506928434,9.84506928434,0.710182217057
|
||||
82.9195512397,82.9195512397,13.3360297918
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0744138036254
|
||||
91.7301596676,91.7301596676,1.94178593423
|
||||
5.54218170236,5.54218170236,0.384966160299
|
||||
35.365405996,35.365405996,3.77132656411
|
||||
7.80223783742,7.80223783742,0.413358257984
|
||||
65.6532097008,65.6532097008,4.86327093046
|
||||
3.25455707226,3.25455707226,0.0718726809146
|
||||
91.8771630371,91.8771630371,10.6019833871
|
||||
9.84506928434,9.84506928434,0.720327677301
|
||||
82.9195512397,82.9195512397,13.5265445031
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0754618853666
|
||||
91.7301596676,91.7301596676,1.96913503189
|
||||
5.54218170236,5.54218170236,0.390388218895
|
||||
35.365405996,35.365405996,3.82444383966
|
||||
7.80223783742,7.80223783742,0.41918020528
|
||||
65.6532097008,65.6532097008,4.93176770412
|
||||
3.25455707226,3.25455707226,0.072884972195
|
||||
91.8771630371,91.8771630371,10.7513070968
|
||||
9.84506928434,9.84506928434,0.730473137544
|
||||
82.9195512397,82.9195512397,13.7170592144
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0765099671078
|
||||
91.7301596676,91.7301596676,1.99648412956
|
||||
5.54218170236,5.54218170236,0.395810277491
|
||||
35.365405996,35.365405996,3.87756111521
|
||||
7.80223783742,7.80223783742,0.425002152575
|
||||
65.6532097008,65.6532097008,5.00026447779
|
||||
3.25455707226,3.25455707226,0.0738972634755
|
||||
91.8771630371,91.8771630371,10.9006308065
|
||||
9.84506928434,9.84506928434,0.740618597788
|
||||
82.9195512397,82.9195512397,13.9075739258
|
||||
;
|
||||
6.2504383551,6.2504383551,0.077558048849
|
||||
91.7301596676,91.7301596676,2.02383322722
|
||||
5.54218170236,5.54218170236,0.401232336087
|
||||
35.365405996,35.365405996,3.93067839076
|
||||
7.80223783742,7.80223783742,0.430824099871
|
||||
65.6532097008,65.6532097008,5.06876125146
|
||||
3.25455707226,3.25455707226,0.074909554756
|
||||
91.8771630371,91.8771630371,11.0499545161
|
||||
9.84506928434,9.84506928434,0.750764058032
|
||||
82.9195512397,82.9195512397,14.0980886371
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0786061305902
|
||||
91.7301596676,91.7301596676,2.05118232489
|
||||
5.54218170236,5.54218170236,0.406654394682
|
||||
35.365405996,35.365405996,3.98379566631
|
||||
7.80223783742,7.80223783742,0.436646047166
|
||||
65.6532097008,65.6532097008,5.13725802513
|
||||
3.25455707226,3.25455707226,0.0759218460365
|
||||
91.8771630371,91.8771630371,11.1992782258
|
||||
9.84506928434,9.84506928434,0.760909518275
|
||||
82.9195512397,82.9195512397,14.2886033484
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0796542123314
|
||||
91.7301596676,91.7301596676,2.07853142255
|
||||
5.54218170236,5.54218170236,0.412076453278
|
||||
35.365405996,35.365405996,4.03691294186
|
||||
7.80223783742,7.80223783742,0.442467994462
|
||||
65.6532097008,65.6532097008,5.2057547988
|
||||
3.25455707226,3.25455707226,0.076934137317
|
||||
91.8771630371,91.8771630371,11.3486019355
|
||||
9.84506928434,9.84506928434,0.771054978519
|
||||
82.9195512397,82.9195512397,14.4791180597
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0807022940726
|
||||
91.7301596676,91.7301596676,2.10588052022
|
||||
5.54218170236,5.54218170236,0.417498511874
|
||||
35.365405996,35.365405996,4.09003021741
|
||||
7.80223783742,7.80223783742,0.448289941757
|
||||
65.6532097008,65.6532097008,5.27425157247
|
||||
3.25455707226,3.25455707226,0.0779464285975
|
||||
91.8771630371,91.8771630371,11.4979256452
|
||||
9.84506928434,9.84506928434,0.781200438763
|
||||
82.9195512397,82.9195512397,14.669632771
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0817503758138
|
||||
91.7301596676,91.7301596676,2.13322961788
|
||||
5.54218170236,5.54218170236,0.42292057047
|
||||
35.365405996,35.365405996,4.14314749296
|
||||
7.80223783742,7.80223783742,0.454111889053
|
||||
65.6532097008,65.6532097008,5.34274834613
|
||||
3.25455707226,3.25455707226,0.078958719878
|
||||
91.8771630371,91.8771630371,11.6472493548
|
||||
9.84506928434,9.84506928434,0.791345899006
|
||||
82.9195512397,82.9195512397,14.8601474823
|
||||
;
|
||||
6.2504383551,6.2504383551,0.082798457555
|
||||
91.7301596676,91.7301596676,2.16057871555
|
||||
5.54218170236,5.54218170236,0.428342629065
|
||||
35.365405996,35.365405996,4.19626476851
|
||||
7.80223783742,7.80223783742,0.459933836348
|
||||
65.6532097008,65.6532097008,5.4112451198
|
||||
3.25455707226,3.25455707226,0.0799710111584
|
||||
91.8771630371,91.8771630371,11.7965730645
|
||||
9.84506928434,9.84506928434,0.80149135925
|
||||
82.9195512397,82.9195512397,15.0506621936
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0838465392963
|
||||
91.7301596676,91.7301596676,2.18792781321
|
||||
5.54218170236,5.54218170236,0.433764687661
|
||||
35.365405996,35.365405996,4.24938204406
|
||||
7.80223783742,7.80223783742,0.465755783644
|
||||
65.6532097008,65.6532097008,5.47974189347
|
||||
3.25455707226,3.25455707226,0.0809833024389
|
||||
91.8771630371,91.8771630371,11.9458967742
|
||||
9.84506928434,9.84506928434,0.811636819494
|
||||
82.9195512397,82.9195512397,15.2411769049
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0848946210375
|
||||
91.7301596676,91.7301596676,2.21527691088
|
||||
5.54218170236,5.54218170236,0.439186746257
|
||||
35.365405996,35.365405996,4.30249931961
|
||||
7.80223783742,7.80223783742,0.47157773094
|
||||
65.6532097008,65.6532097008,5.54823866714
|
||||
3.25455707226,3.25455707226,0.0819955937194
|
||||
91.8771630371,91.8771630371,12.0952204839
|
||||
9.84506928434,9.84506928434,0.821782279737
|
||||
82.9195512397,82.9195512397,15.4316916162
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0859427027787
|
||||
91.7301596676,91.7301596676,2.24262600855
|
||||
5.54218170236,5.54218170236,0.444608804853
|
||||
35.365405996,35.365405996,4.35561659516
|
||||
7.80223783742,7.80223783742,0.477399678235
|
||||
65.6532097008,65.6532097008,5.61673544081
|
||||
3.25455707226,3.25455707226,0.0830078849999
|
||||
91.8771630371,91.8771630371,12.2445441936
|
||||
9.84506928434,9.84506928434,0.831927739981
|
||||
82.9195512397,82.9195512397,15.6222063276
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0869907845199
|
||||
91.7301596676,91.7301596676,2.26997510621
|
||||
5.54218170236,5.54218170236,0.450030863449
|
||||
35.365405996,35.365405996,4.40873387072
|
||||
7.80223783742,7.80223783742,0.483221625531
|
||||
65.6532097008,65.6532097008,5.68523221448
|
||||
3.25455707226,3.25455707226,0.0840201762804
|
||||
91.8771630371,91.8771630371,12.3938679032
|
||||
9.84506928434,9.84506928434,0.842073200225
|
||||
82.9195512397,82.9195512397,15.8127210389
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0880388662611
|
||||
91.7301596676,91.7301596676,2.29732420388
|
||||
5.54218170236,5.54218170236,0.455452922044
|
||||
35.365405996,35.365405996,4.46185114627
|
||||
7.80223783742,7.80223783742,0.489043572826
|
||||
65.6532097008,65.6532097008,5.75372898814
|
||||
3.25455707226,3.25455707226,0.0850324675609
|
||||
91.8771630371,91.8771630371,12.5431916129
|
||||
9.84506928434,9.84506928434,0.852218660468
|
||||
82.9195512397,82.9195512397,16.0032357502
|
||||
;
|
||||
6.2504383551,6.2504383551,0.0890869480023
|
||||
91.7301596676,91.7301596676,2.32467330154
|
||||
5.54218170236,5.54218170236,0.46087498064
|
||||
35.365405996,35.365405996,4.51496842182
|
||||
7.80223783742,7.80223783742,0.494865520122
|
||||
65.6532097008,65.6532097008,5.82222576181
|
||||
3.25455707226,3.25455707226,0.0860447588414
|
||||
91.8771630371,91.8771630371,12.6925153226
|
||||
9.84506928434,9.84506928434,0.862364120712
|
||||
82.9195512397,82.9195512397,16.1937504615
|
||||
;
|
||||
;end
|
Reference in New Issue