-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask.py
58 lines (45 loc) · 1.8 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
RUNNING = 0 # Currently executing on the processor
READY = 1 # Ready to run but task of higher or equal priority is currently running
BLOCKED = 2 # Task is waiting for some condition to be met to move to READY state
SUSPENDED = 3 # Task is waiting for some other task to unsuspend
COMPLETED = 4 # Task is completed
INTERRUPT =0 # Task type is interrupt
PERIODIC =1 # Task type is periodic
APERIODIC =2 # Task type is aperiodic
SPORADIC =3 # Task type is sporadic
class Task (object):
"""Task Object Class
Attributes:
priority (int): Priority of the task
name (str): Name of the task
state (int): State of the task
type (int): Type of the task
act_time (int): Activation time of the task
period (int): Period of the task
wcet (int): Worst case execution time of the task
deadline (int): Deadline of the task
"""
def __init__(self,priority=255,name=None,state=SUSPENDED,type=None,act_time=0,period=0,wcet=0,deadline=1000, relative_deadline=0):
self.priority = priority
self.name = name
self.state = state
self.type = type
self.act_time = act_time
self.period = period
self.wcet = wcet
self.remaining_time = wcet
self.completion_time = None
self.deadline = deadline
self.relative_deadline = relative_deadline
def change_state(self,state) -> None:
"""Change the state of the task
Args:
state (int): New state of the task
"""
self.state = state
def change_priority(self,priority) -> None:
"""Change the priority of the task
Args:
priority (int): New priority of the task
"""
self.priority = priority