RTSA-lab02-SchedTest/schedTests/LiuAndLaylandBound.py

28 lines
821 B
Python
Raw Normal View History

2022-06-01 16:11:48 +02:00
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):
2022-06-24 20:18:19 +02:00
n = tasks.shape[0]
U = TH.getTotalUtilization(tasks=tasks, NrTasks=n)
U_lub = n * ((2 ** (1 / n)) - 1)
# for fewer tasks than 10, we use the exact computed least upper bound
2022-06-27 00:22:45 +02:00
# if n < 10:
# return U <= U_lub
2022-06-01 16:11:48 +02:00
2022-06-24 20:18:19 +02:00
# from 10 tasks up unlimited, we use the limes of n(2 ** 1/n - 1)
2022-06-27 00:22:45 +02:00
return U <= U_lub # np.log(2)
2022-06-01 16:11:48 +02:00