state before helpDesk
This commit is contained in:
parent
49c1a64e52
commit
317b8a1a9c
|
@ -14,15 +14,18 @@ import include.TasksHelper as TH
|
|||
# The number of tasks can be accessed as: tasks.shape[0]
|
||||
|
||||
# The Time Demand Analysis Test
|
||||
|
||||
set_num = 0
|
||||
|
||||
def test(tasks):
|
||||
# Sorting Taskset by Period/Deadline
|
||||
# This makes implementing TDA a lot easier
|
||||
shape = tasks.shape
|
||||
sortedtasks = tasks[tasks[:, 0].argsort()]
|
||||
isSchedulable = True
|
||||
global set_num
|
||||
set_num += 1
|
||||
|
||||
print("\n======= TASK SET =======")
|
||||
print(f"\n======= TASK SET #{set_num} =======\n")
|
||||
# For each tasks in the ordered set
|
||||
for i in range(len(sortedtasks)):
|
||||
|
||||
|
@ -30,25 +33,31 @@ def test(tasks):
|
|||
|
||||
# calculate the time points for the demand function
|
||||
# t = j * P_k for k = 1, 2,...i and j = 1, 2,...,math.ceil(P_i / P_k)
|
||||
list_of_t = [TH.P_i(sortedtasks, k) * j for k in range(1, i)
|
||||
for j in range(1, int(np.ceil(TH.D_i(sortedtasks, i) / TH.P_i(sortedtasks, k))))]
|
||||
# list_of_t = [
|
||||
# j * TH.P_i(sortedtasks, k)
|
||||
# for k in range(i-1)
|
||||
# for j in range(1, int(math.ceil(TH.D_i(sortedtasks, i) / TH.P_i(sortedtasks, k))))
|
||||
# ]
|
||||
# list_of_t = [TH.P_i(sortedtasks, k-1) for k in range(i+1)]
|
||||
list_of_t = []
|
||||
for k in range(i):
|
||||
list_of_t.append(TH.P_i(sortedtasks, k-1))
|
||||
|
||||
# print(f'\t list of ts: {list_of_t}')
|
||||
print(f'\t list of t: {list_of_t}')
|
||||
|
||||
# at any time t between 0 and and TH.P_i
|
||||
for t in np.sort(list_of_t):
|
||||
# for t in range(TH.C_i(sortedtasks, i), TH.P_i(sortedtasks, i)+1, TH.P_i(sortedtasks, i)):
|
||||
|
||||
print(f'\tTime-Demand for t ({t}): {time_demand_func(sortedtasks, i, t)} ')
|
||||
for j in range(len(list_of_t)):
|
||||
# for t in range(int(TH.C_i(sortedtasks, i)), int(TH.P_i(sortedtasks, i)+1), int(step)):
|
||||
|
||||
# if the demand for CPU time of task i exceeds the available time t
|
||||
if time_demand_func(sortedtasks, i, t) > t:
|
||||
return False # then the task i will not meet its deadline, hence taskset not schedulable
|
||||
return True
|
||||
if time_demand_func(sortedtasks, i, list_of_t[j]) > list_of_t[j]:
|
||||
isSchedulable = False # then the task i will not meet its deadline, hence taskset not schedulable
|
||||
print(f'\t time-demand for t := {list_of_t[j]} ---> {time_demand_func(sortedtasks, i, list_of_t[j])} is schedulable: {isSchedulable}')
|
||||
return isSchedulable
|
||||
|
||||
|
||||
def time_demand_func(tasks, i, delta=0):
|
||||
def time_demand_func(tasks, i, t):
|
||||
sum = 0
|
||||
for k in range(1, i-1):
|
||||
sum += math.ceil(delta / TH.P_i(tasks, k)) * TH.C_i(tasks, k)
|
||||
for k in range(i-1):
|
||||
sum += math.ceil(t / TH.P_i(tasks, k)) * TH.C_i(tasks, k)
|
||||
return TH.C_i(tasks, i) + sum
|
||||
|
|
Loading…
Reference in New Issue