-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task.py
35 lines (30 loc) · 1.17 KB
/
Task.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
class Task:
def __init__(self, period=0, release=0, deadline=0, exec_time=0, blk_st=0, blk_dur=0):
self.period = period
self.release = release
self.deadline = deadline # relative
self.exec_time = exec_time
self.blocking_start = blk_st
self.blocking_duration = blk_dur
self.priority = None
def __lt__(self, other):
return self.priority < other.priority
class Job:
def __init__(self, task: Task, time):
self.task = task
self.exec_time = task.exec_time # remaining execution time
self.release = time
self.deadline = self.release + task.deadline if task.deadline != 0 else 0
self.blocking_start = task.blocking_start + self.release
self.blocking_duration = task.blocking_duration
self.priority = None
self.has_run = False
def __lt__(self, other):
if self.priority == other.priority and self.has_run == True and other.has_run == False:
return True
else:
self.priority > other.priority
class Problem:
def __init__(self, tasks=[], hyper_period=0):
self.tasks = tasks
self.hyper_period = hyper_period