Commit ab0cc5e1 by Michael Schmid

seems to work with a few bugs

parent 930ac7c0
...@@ -6,7 +6,7 @@ from simso.core.JobEvent import JobEvent ...@@ -6,7 +6,7 @@ from simso.core.JobEvent import JobEvent
from math import ceil from math import ceil
class Job(Process): class Job:
"""The Job class simulate the behavior of a real Job. This *should* only be """The Job class simulate the behavior of a real Job. This *should* only be
instantiated by a Task.""" instantiated by a Task."""
...@@ -28,7 +28,6 @@ class Job(Process): ...@@ -28,7 +28,6 @@ class Job(Process):
:type etm: AbstractExecutionTimeModel :type etm: AbstractExecutionTimeModel
:type sim: Model :type sim: Model
""" """
Process.__init__(self, env=sim,generator=self.activate_job())
self._task = task self._task = task
self._pred = pred self._pred = pred
self.instr_count = 0 # Updated by the cache model. self.instr_count = 0 # Updated by the cache model.
...@@ -53,7 +52,9 @@ class Job(Process): ...@@ -53,7 +52,9 @@ class Job(Process):
self.processor_ok = self._sim.event() self.processor_ok = self._sim.event()
self.context_ok = self._sim.event() self.context_ok = self._sim.event()
self.context_ok.succeed() self.context_ok.succeed()
self.context_ready=True self.context_ready = True
self.process = self._sim.process(self.activate_job())
def is_active(self): def is_active(self):
""" """
......
...@@ -134,11 +134,11 @@ class Model(Environment): ...@@ -134,11 +134,11 @@ class Model(Environment):
self.scheduler.init() self.scheduler.init()
self.progress.start() self.progress.start()
for cpu in self._processors: # for cpu in self._processors:
self.process(cpu.run()) # self.process(cpu.run())
for task in self._task_list: # for task in self._task_list:
self.process(task.execute()) # self.process(task.execute())
try: try:
self.run(until=self._duration) self.run(until=self._duration)
......
...@@ -34,7 +34,7 @@ class ProcInfo(object): ...@@ -34,7 +34,7 @@ class ProcInfo(object):
self.caches.append(cache) self.caches.append(cache)
class Processor(Process): class Processor:
""" """
A processor is responsible of deciding whether the simulated processor A processor is responsible of deciding whether the simulated processor
should execute a job or execute the scheduler. There is one instance of should execute a job or execute the scheduler. There is one instance of
...@@ -54,7 +54,6 @@ class Processor(Process): ...@@ -54,7 +54,6 @@ class Processor(Process):
cls._identifier = 0 cls._identifier = 0
def __init__(self, model, proc_info): def __init__(self, model, proc_info):
Process.__init__(self, model, self.run())
self._model = model self._model = model
self._internal_id = Processor._identifier self._internal_id = Processor._identifier
Processor._identifier += 1 Processor._identifier += 1
...@@ -74,6 +73,7 @@ class Processor(Process): ...@@ -74,6 +73,7 @@ class Processor(Process):
self.timer_monitor = Monitor( self.timer_monitor = Monitor(
env=model, name="Monitor Timer" + proc_info.name) env=model, name="Monitor Timer" + proc_info.name)
self._speed = proc_info.speed self._speed = proc_info.speed
self.process = self._model.process(self.run())
def resched(self): def resched(self):
""" """
...@@ -169,7 +169,8 @@ class Processor(Process): ...@@ -169,7 +169,8 @@ class Processor(Process):
while not self._evts: while not self._evts:
yield self._model.timeout(1) yield self._model.timeout(1)
if job: if job:
self._model.interrupt(job) # self._model.interrupt(job)
# job.process.interrupt()
self.monitor.observe(ProcCxtSaveEvent()) self.monitor.observe(ProcCxtSaveEvent())
# overhead save context # overhead save context
yield self._model.timeout(self.cs_overhead) yield self._model.timeout(self.cs_overhead)
......
...@@ -107,7 +107,7 @@ class TaskInfo(object): ...@@ -107,7 +107,7 @@ class TaskInfo(object):
return stack return stack
class GenericTask(Process): class GenericTask:
""" """
Abstract class for Tasks. :class:`ATask` and :class:`PTask` inherits from Abstract class for Tasks. :class:`ATask` and :class:`PTask` inherits from
this class. this class.
...@@ -132,7 +132,6 @@ class GenericTask(Process): ...@@ -132,7 +132,6 @@ class GenericTask(Process):
:type sim: Model :type sim: Model
:type task_info: TaskInfo :type task_info: TaskInfo
""" """
Process.__init__(self, env=sim, generator=self.execute())
self.name = task_info.name self.name = task_info.name
self._task_info = task_info self._task_info = task_info
self._monitor = Monitor(name="Monitor" + self.name + "_states", self._monitor = Monitor(name="Monitor" + self.name + "_states",
...@@ -146,6 +145,7 @@ class GenericTask(Process): ...@@ -146,6 +145,7 @@ class GenericTask(Process):
self._cpi_alone = {} self._cpi_alone = {}
self._jobs = [] self._jobs = []
self.job = None self.job = None
self.process = self._sim.process(self.execute())
def execute(self): def execute(self):
pass pass
...@@ -340,7 +340,7 @@ class SporadicTask(GenericTask): ...@@ -340,7 +340,7 @@ class SporadicTask(GenericTask):
self._init() self._init()
for ndate in self.list_activation_dates: for ndate in self.list_activation_dates:
yield self._sim.timeout(int(ndate * self._sim.cycles_per_ms) \ yield self._sim.timeout(int(ndate * self._sim.cycles_per_ms)
- self._sim.now) - self._sim.now)
self.create_job() self.create_job()
...@@ -360,7 +360,7 @@ class ProbabilisticTask(GenericTask): ...@@ -360,7 +360,7 @@ class ProbabilisticTask(GenericTask):
self._init() self._init()
for ndate in self.list_activation_dates: for ndate in self.list_activation_dates:
yield self._sim.timeout(int(ndate * self._sim.cycles_per_ms) \ yield self._sim.timeout(int(ndate * self._sim.cycles_per_ms)
- self._sim.now) - self._sim.now)
self.create_job() self.create_job()
......
...@@ -6,9 +6,8 @@ from simpy import Environment, Process, Interrupt ...@@ -6,9 +6,8 @@ from simpy import Environment, Process, Interrupt
# TODO: allow the user to specify an overhead. # TODO: allow the user to specify an overhead.
class InstanceTimer(Process): class InstanceTimer:
def __init__(self, timer): def __init__(self, timer):
Process.__init__(self, env=timer._sim, generator=self.run())
self._sim = timer._sim self._sim = timer._sim
self.function = timer.function self.function = timer.function
self.args = timer.args self.args = timer.args
...@@ -17,6 +16,7 @@ class InstanceTimer(Process): ...@@ -17,6 +16,7 @@ class InstanceTimer(Process):
self.cpu = timer.cpu self.cpu = timer.cpu
self.running = False self.running = False
self.overhead = timer.overhead self.overhead = timer.overhead
self.process = self._sim.process(self.run())
def call_handler(self): def call_handler(self):
if self.running: if self.running:
...@@ -54,6 +54,7 @@ class Timer(object): ...@@ -54,6 +54,7 @@ class Timer(object):
The delay is expressed in milliseconds by default but it can also be given The delay is expressed in milliseconds by default but it can also be given
in cycles. in cycles.
""" """
def __init__(self, sim, function, args, delay, one_shot=True, prior=False, def __init__(self, sim, function, args, delay, one_shot=True, prior=False,
cpu=None, in_ms=True, overhead=0): cpu=None, in_ms=True, overhead=0):
""" """
...@@ -95,7 +96,8 @@ class Timer(object): ...@@ -95,7 +96,8 @@ class Timer(object):
Start the timer. Start the timer.
""" """
self.instance = InstanceTimer(self) self.instance = InstanceTimer(self)
self._sim.process(self.instance.run()) # TODO: , self.prior what's with this? # TODO: , self.prior what's with this?
self._sim.process(self.instance.run())
def stop(self): def stop(self):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment