Commit 6ae843e2 by Michael Schmid

Moved to simpy4 processes

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