From: <jsa...@us...> - 2009-02-11 19:05:25
|
Revision: 130 http://flexotask.svn.sourceforge.net/flexotask/?rev=130&view=rev Author: jsauerbach Date: 2009-02-11 19:05:19 +0000 (Wed, 11 Feb 2009) Log Message: ----------- Add some paranoid checking to find errors where a scheduler is running a connection and one of its contiguous tasks simultaneously. Unfortunately, the error comes out as OutOfMemory on a particular line rather than something more informative. To be improved. Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/system/ConnectionDriverImpl.java trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskControllerImpl.java trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskValidator.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/system/ConnectionDriverImpl.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/system/ConnectionDriverImpl.java 2009-02-09 18:26:28 UTC (rev 129) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/system/ConnectionDriverImpl.java 2009-02-11 19:05:19 UTC (rev 130) @@ -26,12 +26,18 @@ /** The OutputPort of the connection's input */ private final FlexotaskOutputPortImpl input; + /** The FlexotaskController in charge of the connection's input (for concurrency checking) */ + private FlexotaskControllerImpl inputController; + /** The name of the connection to use for tracing */ private String name; /** The InputPort of the connection's output */ private final FlexotaskInputPortImpl output; + /** The FlexotaskController in charge of the connection's output (for concurrency checking) */ + private FlexotaskControllerImpl outputController; + /** The FlexotaskTracer to use for tracing */ private FlexotaskTracer tracer; @@ -57,42 +63,17 @@ } /* (non-Javadoc) - * @see com.ibm.realtime.flexotask.system.ConnectionDriver#peekOutputPort() - */ - public Object peekOutputPort() { - return input.peek(); - } - - /* (non-Javadoc) - * @see com.ibm.realtime.flexotask.system.ConnectionDriver#peekOutputPort(int) - */ - public Object peekOutputPort(int index) { - return input.peek(index); - } - - /* (non-Javadoc) - * @see com.ibm.realtime.flexotask.system.ConnectionDriver#peekInputPort() - */ - public Object peekInputPort() { - return output.peek(); - } - - /* (non-Javadoc) - * @see com.ibm.realtime.flexotask.system.ConnectionDriver#peekInputPort(int) - */ - public Object peekInputPort(int index) { - return output.peek(index); - } - - - /* (non-Javadoc) * @see com.ibm.realtime.flexotask.system.ConnectionDriver#copy() */ public void copy() { + inputController.occupied(true); + outputController.occupied(true); tracer.startRun(); copyOrMove(input.peek()); tracer.endRun(); + inputController.occupied(false); + outputController.occupied(false); } /* (non-Javadoc) @@ -100,16 +81,46 @@ */ public void copy(int index) { + inputController.occupied(true); + outputController.occupied(true); tracer.startRun(); copyOrMove(input.peek(index)); tracer.endRun(); + inputController.occupied(false); + outputController.occupied(false); } + public boolean equals(Object o) { + ConnectionDriverImpl driver = (ConnectionDriverImpl) o; + return name.equals(driver.name); + } + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.system.ConnectionDriver#getInputUpdatedCount() + */ + public long getInputUpdatedCount() { + inputController.occupied(true); + long ans = input.getUpdatedCount(); + inputController.occupied(false); + return ans; + } + + + /** + * both of the hashCode and equals methods assumes the connection names are unique in the system. + */ + public int hashCode() { + return name.hashCode(); + } + + /* (non-Javadoc) * @see com.ibm.realtime.flexotask.system.ConnectionDriver#hasPendingInput() */ public boolean hasPendingInput() { - return !input.isEmpty(); + inputController.occupied(true); + boolean ans = !input.isEmpty(); + inputController.occupied(false); + return ans; } /* (non-Javadoc) @@ -117,12 +128,56 @@ */ public void move() { + inputController.occupied(true); + outputController.occupied(true); tracer.startRun(); copyOrMove(input.remove()); tracer.endRun(); + inputController.occupied(false); + outputController.occupied(false); } /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.system.ConnectionDriver#peekInputPort() + */ + public Object peekInputPort() { + outputController.occupied(true); + Object ans = output.peek(); + outputController.occupied(false); + return ans; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.system.ConnectionDriver#peekInputPort(int) + */ + public Object peekInputPort(int index) { + outputController.occupied(true); + Object ans = output.peek(index); + outputController.occupied(false); + return ans; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.system.ConnectionDriver#peekOutputPort() + */ + public Object peekOutputPort() { + inputController.occupied(true); + Object ans = input.peek(); + inputController.occupied(false); + return ans; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.system.ConnectionDriver#peekOutputPort(int) + */ + public Object peekOutputPort(int index) { + inputController.occupied(true); + Object ans = input.peek(index); + inputController.occupied(false); + return ans; + } + + /* (non-Javadoc) * @see java.lang.Runnable#run() */ /* (non-Javadoc) @@ -133,14 +188,30 @@ /* Default behavior is copy (for backward compatibility) but it is probably better to call copy() or move() explicitly */ copy(); } - + // @see java.lang.Object#toString() public String toString() { return name; } + + /** + * Set the input controller (called by the validator after both the connection and the controller have been created) + * @param inputController the input controller for the connection + */ + void setInputController(FlexotaskControllerImpl inputController) { + this.inputController = inputController; + } + + /** + * Set the output controller (called by the validator after both the connection and the controller have been created) + * @param outputController the output controller for the connection + */ + void setOutputController(FlexotaskControllerImpl outputController) { + this.outputController = outputController; + } - /** + /** * Code common to copy and move * @param inObj the input object acquired either by peek or remove */ @@ -185,23 +256,4 @@ } name = inputTask.taskName + " " + inIndex + " -> " + outputTask.taskName + " " + outIndex; } - - /* (non-Javadoc) - * @see com.ibm.realtime.flexotask.system.ConnectionDriver#getInputUpdatedCount() - */ - public long getInputUpdatedCount() { - return input.getUpdatedCount(); - } - - /** - * both of the hashCode and equals methods assumes the connection names are unique in the system. - */ - public int hashCode() { - return name.hashCode(); - } - - public boolean equals(Object o) { - ConnectionDriverImpl driver = (ConnectionDriverImpl) o; - return name.equals(driver.name); - } } Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskControllerImpl.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskControllerImpl.java 2009-02-09 18:26:28 UTC (rev 129) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskControllerImpl.java 2009-02-11 19:05:19 UTC (rev 130) @@ -61,6 +61,18 @@ return true; } + public boolean equals(Object o) { + FlexotaskControllerImpl controller = (FlexotaskControllerImpl)o; + return taskName.equals(controller.taskName); + } + + /** + * both of the hashCode and equals methods assumes the task names are unique in the system. + */ + public int hashCode() { + return taskName.hashCode(); + } + /* (non-Javadoc) * @see com.ibm.realtime.flexotask.system.FlexotaskController#run() */ @@ -84,34 +96,22 @@ tracer.endRun(); occupied(false); } - + + // @see java.lang.Object#toString() + public String toString() + { + return taskName; + } + /** * Ensures only one thread running each task * @param toOccupy true if thread is running or collecting a task, false if done */ - private synchronized void occupied(boolean toOccupy) + synchronized void occupied(boolean toOccupy) { if (toOccupy && occupied) { throw new IllegalStateException("More than one thread simultaneously running " + taskName); } occupied = toOccupy; } - - // @see java.lang.Object#toString() - public String toString() - { - return taskName; - } - - /** - * both of the hashCode and equals methods assumes the task names are unique in the system. - */ - public int hashCode() { - return taskName.hashCode(); - } - - public boolean equals(Object o) { - FlexotaskControllerImpl controller = (FlexotaskControllerImpl)o; - return taskName.equals(controller.taskName); - } } Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskValidator.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskValidator.java 2009-02-09 18:26:28 UTC (rev 129) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskValidator.java 2009-02-11 19:05:19 UTC (rev 130) @@ -35,7 +35,6 @@ import com.ibm.realtime.flexotask.distribution.FlexotaskDistributerRegistry; import com.ibm.realtime.flexotask.distribution.FlexotaskDistributionContext; import com.ibm.realtime.flexotask.distribution.FlexotaskTimerService; -import com.ibm.realtime.flexotask.scheduling.ConnectionDriver; import com.ibm.realtime.flexotask.scheduling.FlexotaskController; import com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler; import com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulerRegistry; @@ -473,7 +472,7 @@ FlexotaskControllerImpl targetController = (FlexotaskControllerImpl) taskMap.get(target); FlexotaskInputPortImpl targetPort = (FlexotaskInputPortImpl) targetController.root.getInputPorts()[conn.getInputPortToWrite()]; FlexotaskConnectionMode mode = conn.getConnectionMode(); - ConnectionDriver driver; + ConnectionDriverImpl driver; if (targetController instanceof AtomicFlexotaskController) { driver = new AtomicConnectionDriver(sourcePort, sourceController, targetPort, targetController, mode, tracer); @@ -481,6 +480,8 @@ driver = new ConnectionDriverImpl(sourcePort, sourceController, targetPort, targetController, mode, tracer); } + driver.setInputController(sourceController); + driver.setOutputController(targetController); instantiationMap.put(conn, driver); } /* Move the task instantiations from the temporary taskMap to the instantiationMap */ @@ -630,10 +631,6 @@ if (flexotask instanceof AtomicFlexotask) { TransactionalOperations.registerFields(((AtomicFlexotask) flexotask).getReachableFieldTable()); } - /* If the Flexotask is time-aware, set its timer */ - if (flexotask instanceof TimeAware) { - ((TimeAware) flexotask).setTimer(timer); - } /* If the Flexotask is strongly isolated, clone its parameter */ if (!task.isWeaklyIsolated()) { parameter = FlexotaskSystemSupport.deepClone(parameter, null); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |