From 6ae843e2abd6c99c9299af4d6def51ace35bf937 Mon Sep 17 00:00:00 2001 From: Michael Schmid Date: Tue, 1 Dec 2020 11:38:01 +0100 Subject: [PATCH] Moved to simpy4 processes --- script.py | 3 ++- simso/core/Job.py | 7 +++---- simso/core/Processor.py | 21 ++++++++++----------- simso/core/Task.py | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/script.py b/script.py index 1a4001d..6506fe1 100755 --- a/script.py +++ b/script.py @@ -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) diff --git a/simso/core/Job.py b/simso/core/Job.py index ce2f45c..b0d4aec 100644 --- a/simso/core/Job.py +++ b/simso/core/Job.py @@ -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() diff --git a/simso/core/Processor.py b/simso/core/Processor.py index 4bc755d..82a5dc5 100644 --- a/simso/core/Processor.py +++ b/simso/core/Processor.py @@ -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: diff --git a/simso/core/Task.py b/simso/core/Task.py index 0f12107..61bb8ed 100644 --- a/simso/core/Task.py +++ b/simso/core/Task.py @@ -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) -- libgit2 0.26.0