Commit ab0cc5e1 by Michael Schmid

seems to work with a few bugs

parent 930ac7c0
......@@ -6,7 +6,7 @@ from simso.core.JobEvent import JobEvent
from math import ceil
class Job(Process):
class Job:
"""The Job class simulate the behavior of a real Job. This *should* only be
instantiated by a Task."""
......@@ -28,7 +28,6 @@ class Job(Process):
:type etm: AbstractExecutionTimeModel
:type sim: Model
"""
Process.__init__(self, env=sim,generator=self.activate_job())
self._task = task
self._pred = pred
self.instr_count = 0 # Updated by the cache model.
......@@ -53,7 +52,9 @@ class Job(Process):
self.processor_ok = self._sim.event()
self.context_ok = self._sim.event()
self.context_ok.succeed()
self.context_ready=True
self.context_ready = True
self.process = self._sim.process(self.activate_job())
def is_active(self):
"""
......@@ -92,7 +93,7 @@ class Job(Process):
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("Don't know what to pass else?"), kernel=True) # TODO: what to pass as interrupted?
def _on_terminated(self):
self._on_stop_exec()
......@@ -302,7 +303,7 @@ class Job(Process):
# Wait an execute order.
try:
yield self.processor_ok
self.processor_ok = self._sim.event()
self.processor_ok = self._sim.event()
except Interrupt:
pass
else:
......
......@@ -48,7 +48,7 @@ class Model(Environment):
# Init the processor class. This will in particular reinit the
# identifiers to 0.
Processor.init()
# Initialization of the caches
for cache in configuration.caches_list:
cache.init()
......@@ -134,11 +134,11 @@ class Model(Environment):
self.scheduler.init()
self.progress.start()
for cpu in self._processors:
self.process(cpu.run())
# for cpu in self._processors:
# self.process(cpu.run())
for task in self._task_list:
self.process(task.execute())
# for task in self._task_list:
# self.process(task.execute())
try:
self.run(until=self._duration)
......
......@@ -34,7 +34,7 @@ class ProcInfo(object):
self.caches.append(cache)
class Processor(Process):
class Processor:
"""
A processor is responsible of deciding whether the simulated processor
should execute a job or execute the scheduler. There is one instance of
......@@ -54,7 +54,6 @@ class Processor(Process):
cls._identifier = 0
def __init__(self, model, proc_info):
Process.__init__(self, model, self.run())
self._model = model
self._internal_id = Processor._identifier
Processor._identifier += 1
......@@ -74,6 +73,7 @@ class Processor(Process):
self.timer_monitor = Monitor(
env=model, name="Monitor Timer" + proc_info.name)
self._speed = proc_info.speed
self.process = self._model.process(self.run())
def resched(self):
"""
......@@ -169,7 +169,8 @@ class Processor(Process):
while not self._evts:
yield self._model.timeout(1)
if job:
self._model.interrupt(job)
# self._model.interrupt(job)
# job.process.interrupt()
self.monitor.observe(ProcCxtSaveEvent())
# overhead save context
yield self._model.timeout(self.cs_overhead)
......
......@@ -107,7 +107,7 @@ class TaskInfo(object):
return stack
class GenericTask(Process):
class GenericTask:
"""
Abstract class for Tasks. :class:`ATask` and :class:`PTask` inherits from
this class.
......@@ -132,7 +132,6 @@ class GenericTask(Process):
:type sim: Model
:type task_info: TaskInfo
"""
Process.__init__(self, env=sim, generator=self.execute())
self.name = task_info.name
self._task_info = task_info
self._monitor = Monitor(name="Monitor" + self.name + "_states",
......@@ -146,6 +145,7 @@ class GenericTask(Process):
self._cpi_alone = {}
self._jobs = []
self.job = None
self.process = self._sim.process(self.execute())
def execute(self):
pass
......@@ -321,7 +321,7 @@ class PTask(GenericTask):
self._init()
# wait the activation date.
yield self._sim.timeout(int(self._task_info.activation_date *
self._sim.cycles_per_ms))
self._sim.cycles_per_ms))
while True:
# print self.sim.now, "activate", self.name
......@@ -340,8 +340,8 @@ class SporadicTask(GenericTask):
self._init()
for ndate in self.list_activation_dates:
yield self._sim.timeout(int(ndate * self._sim.cycles_per_ms) \
- self._sim.now)
yield self._sim.timeout(int(ndate * self._sim.cycles_per_ms)
- self._sim.now)
self.create_job()
@property
......@@ -360,8 +360,8 @@ class ProbabilisticTask(GenericTask):
self._init()
for ndate in self.list_activation_dates:
yield self._sim.timeout(int(ndate * self._sim.cycles_per_ms) \
- self._sim.now)
yield self._sim.timeout(int(ndate * self._sim.cycles_per_ms)
- self._sim.now)
self.create_job()
@property
......
......@@ -6,9 +6,8 @@ from simpy import Environment, Process, Interrupt
# TODO: allow the user to specify an overhead.
class InstanceTimer(Process):
class InstanceTimer:
def __init__(self, timer):
Process.__init__(self, env=timer._sim, generator=self.run())
self._sim = timer._sim
self.function = timer.function
self.args = timer.args
......@@ -17,6 +16,7 @@ class InstanceTimer(Process):
self.cpu = timer.cpu
self.running = False
self.overhead = timer.overhead
self.process = self._sim.process(self.run())
def call_handler(self):
if self.running:
......@@ -54,6 +54,7 @@ class Timer(object):
The delay is expressed in milliseconds by default but it can also be given
in cycles.
"""
def __init__(self, sim, function, args, delay, one_shot=True, prior=False,
cpu=None, in_ms=True, overhead=0):
"""
......@@ -95,7 +96,8 @@ class Timer(object):
Start the timer.
"""
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):
"""
......
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