Commit 6ae843e2 by Michael Schmid

Moved to simpy4 processes

parent ab0cc5e1
......@@ -19,7 +19,7 @@ def main(argv):
configuration.cycles_per_ms = 1
configuration.duration = 420 * configuration.cycles_per_ms
configuration.duration = 20 * configuration.cycles_per_ms
# Add tasks:
configuration.add_task(name="T1", identifier=1, period=7,
......@@ -49,4 +49,5 @@ def main(argv):
for log in model.logs:
print(log)
main(sys.argv)
......@@ -49,12 +49,11 @@ class Job:
self._on_activate()
self.process = None
self.processor_ok = self._sim.event()
self.context_ok = self._sim.event()
self.context_ok.succeed()
self.context_ready = True
self.process = self._sim.process(self.activate_job())
def is_active(self):
"""
......@@ -93,7 +92,7 @@ class Job:
self._monitor.observe(JobEvent(self, JobEvent.PREEMPTED))
self._sim.logger.log(self.name + " Preempted! ret: " +
str("Don't know what to pass else?"), kernel=True) # TODO: what to pass as interrupted?
str(self.ret), kernel=True) # TODO: what to pass as interrupted?
def _on_terminated(self):
self._on_stop_exec()
......
......@@ -150,33 +150,32 @@ class Processor:
if not self._evts:
job = self._running
if job:
# yield job.context_ok
while not job.context_ready:
yield self._model.timeout(1)
yield job.context_ok
self.monitor.observe(ProcCxtLoadEvent())
# overhead load context
yield self._model.timeout(self.cl_overhead)
self.monitor.observe(ProcCxtLoadEvent(terminated=True))
# job.interruptReset() # TODO: does this interrupt need handling?
job.processor_ok.succeed()
job.processor_ok = self._model.event()
self.monitor.observe(ProcRunEvent(job))
job.context_ready = False
else:
self.monitor.observe(ProcIdleEvent())
# Wait event.
first_yield = True
while not self._evts:
yield self._model.timeout(1)
if job:
# self._model.interrupt(job)
# job.process.interrupt()
if first_yield:
yield self._model.timeout(0)
first_yield = False
else:
yield self._model.timeout(1)
if job and job.is_active():
job.process.interrupt()
self.monitor.observe(ProcCxtSaveEvent())
# overhead save context
yield self._model.timeout(self.cs_overhead)
self.monitor.observe(ProcCxtSaveEvent(terminated=True))
# job.context_ok = self._model.event()
job.context_ready = True
job.context_ok = self._model.event()
evt = self._evts.popleft()
if evt[0] == RESCHED:
......
......@@ -285,7 +285,7 @@ class GenericTask:
if len(self._activations_fifo) == 0:
self.job = job
self._sim.process(job.activate_job())
job.process = self._sim.process(job.activate_job())
self._activations_fifo.append(job)
self._jobs.append(job)
......
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