Commit f0cc5d49 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Ioannis Papagiannopoulos

examples with failures seem to work. Cleanup needed

parent 05bfdc25
...@@ -57,6 +57,7 @@ class CoreObject(Process): ...@@ -57,6 +57,7 @@ class CoreObject(Process):
self.isRequested=SimEvent('isRequested') self.isRequested=SimEvent('isRequested')
self.canDispose=SimEvent('canDispose') self.canDispose=SimEvent('canDispose')
self.interruptionEnd=SimEvent('interruptionEnd') self.interruptionEnd=SimEvent('interruptionEnd')
self.interruptionStart=SimEvent('interruptionStart')
def initialize(self): def initialize(self):
# XXX why call super.__init__ outside of __init__ ? # XXX why call super.__init__ outside of __init__ ?
......
...@@ -112,9 +112,9 @@ class Failure(ObjectInterruption): ...@@ -112,9 +112,9 @@ class Failure(ObjectInterruption):
yield release,self,self.repairman.getResource() yield release,self,self.repairman.getResource()
self.repairman.totalWorkingTime+=now()-timeOperationStarted self.repairman.totalWorkingTime+=now()-timeOperationStarted
#=========================================================================== # #===========================================================================
# interrupts the victim # # interrupts the victim
#=========================================================================== # #===========================================================================
def interruptVictim(self): # def interruptVictim(self):
ObjectInterruption.interrupt(self) # ObjectInterruption.interrupt(self)
# TODO: check whether it is a good idea to update the failure timers here # # TODO: check whether it is a good idea to update the failure timers here
\ No newline at end of file \ No newline at end of file
...@@ -454,16 +454,18 @@ class Machine(CoreObject): ...@@ -454,16 +454,18 @@ class Machine(CoreObject):
if not self.signalReceiver(): if not self.signalReceiver():
# if there was no available receiver, get into blocking control # if there was no available receiver, get into blocking control
while 1: while 1:
# wait the event canDispose, this means that the station can deliver the item to successor # wait the event canDispose, this means that the station can deliver the item to successor
yield waitevent, self, self.canDispose event=yield waitevent, self, [self.canDispose, self.interruptionStart]
# if there was interruption # if there was interruption
if self.interrupted(): #if self.interrupted():
# TODO not good implementation
if self.interruptionStart.signalparam==now():
# wait for the end of the interruption # wait for the end of the interruption
self.interruptionActions() # execute interruption actions self.interruptionActions() # execute interruption actions
yield waitevent, self, self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption yield waitevent, self, self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
assert self==self.interruptionEnd.signalparam, 'the victim of the failure is not the object that received it' assert self==self.interruptionEnd.signalparam, 'the victim of the failure is not the object that received it'
self.postInterruptionActions() self.postInterruptionActions()
#======================================================= #=======================================================
# TODO: not sure if this is required now # TODO: not sure if this is required now
# #if during the interruption the object became empty break # #if during the interruption the object became empty break
......
...@@ -85,11 +85,12 @@ class ObjectInterruption(Process): ...@@ -85,11 +85,12 @@ class ObjectInterruption(Process):
#interrupts the victim #interrupts the victim
def interruptVictim(self): def interruptVictim(self):
self.interrupt(self.victim) self.interrupt(self.victim)
self.victim.interruptionStart.signal(now())
#reactivate the victim #reactivate the victim
def reactivateVictim(self): def reactivateVictim(self):
self.victim.interruptionEnd.signal(victim) self.victim.interruptionEnd.signal(self.victim)
# reactivate(self.victim) # reactivate(self.victim)
#outputs message to the trace.xls. Format is (Simulation Time | Victim Name | message) #outputs message to the trace.xls. Format is (Simulation Time | Victim Name | message)
......
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 to comment