-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
372 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from amitools.vamos.schedule import SchedulerEvent | ||
|
||
|
||
class ExecScheduler: | ||
"""The ExecScheduler syns the scheduler state into the ExecLibrary""" | ||
|
||
def __init__(self, scheduler, exec_lib): | ||
self.scheduler = scheduler | ||
self.exec_lib = exec_lib | ||
# handle scheduler events | ||
self.old_task = None | ||
self.scheduler.set_event_callback(self.event_handler) | ||
|
||
def event_handler(self, event): | ||
ev = event.type | ||
# lookup scheduler and ami task | ||
sched_task = event.task | ||
if sched_task: | ||
ami_task = sched_task.map_task.ami_task | ||
else: | ||
ami_task = None | ||
|
||
if ev == SchedulerEvent.Type.ACTIVE_TASK: | ||
# remove from task_ready | ||
if ami_task: | ||
ami_task.node.remove() | ||
# store in ThisTask | ||
self.exec_lib.this_task.ref = ami_task | ||
elif ev == SchedulerEvent.Type.READY_TASK: | ||
# add to task_ready | ||
self.exec_lib.task_ready.add_head(ami_task.node) | ||
elif ev == SchedulerEvent.Type.WAITING_TASK: | ||
# add to task_wait | ||
self.exec_lib.task_wait.add_head(ami_task.node) | ||
elif ev == SchedulerEvent.Type.WAKE_UP_TASK: | ||
# remove from task_wait and add to ready | ||
ami_task.node.remove() | ||
self.exec_lib.task_ready.add_head(ami_task.node) | ||
elif ev == SchedulerEvent.Type.ADD_TASK: | ||
self.exec_lib.task_ready.add_tail(ami_task.node) |
Oops, something went wrong.