You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(28) |
Nov
(60) |
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(7) |
Feb
(23) |
Mar
(1) |
Apr
(12) |
May
|
Jun
(12) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jhs...@us...> - 2009-04-12 15:34:11
|
Revision: 147 http://flexotask.svn.sourceforge.net/flexotask/?rev=147&view=rev Author: jhspring Date: 2009-04-12 15:34:08 +0000 (Sun, 12 Apr 2009) Log Message: ----------- Initial import. Added Paths: ----------- flexotask-streaming/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jhs...@us...> - 2009-04-11 17:13:14
|
Revision: 146 http://flexotask.svn.sourceforge.net/flexotask/?rev=146&view=rev Author: jhspring Date: 2009-04-11 17:13:05 +0000 (Sat, 11 Apr 2009) Log Message: ----------- See 2750827 Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/validation/CommonCodeValidator.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/validation/CommonCodeValidator.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/validation/CommonCodeValidator.java 2009-03-10 14:00:34 UTC (rev 145) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/validation/CommonCodeValidator.java 2009-04-11 17:13:05 UTC (rev 146) @@ -42,6 +42,9 @@ import com.ibm.realtime.flexotask.FlexotaskOutputPort; import com.ibm.realtime.flexotask.system.FlexotaskSystemSupport; import com.ibm.realtime.flexotask.system.TransactionalOperations; +import com.ibm.realtime.flexotask.template.FlexotaskConnectionMode; +import com.ibm.realtime.flexotask.template.FlexotaskConnectionTemplate; +import com.ibm.realtime.flexotask.template.FlexotaskPortTemplate; import com.ibm.realtime.flexotask.template.FlexotaskStableMode; import com.ibm.realtime.flexotask.template.FlexotaskTaskTemplate; import com.ibm.realtime.flexotask.template.FlexotaskTemplate; @@ -313,6 +316,29 @@ } } } + /* Check port semantics */ + for (Iterator iter = template.getConnections().iterator(); iter.hasNext();) { + FlexotaskConnectionTemplate element = (FlexotaskConnectionTemplate) iter.next(); + /* we do not check BYREF connections as we do not know the allocation + * context of the objects being written to the output port, which is + * what we're interested in for BYREF connections. Thus, this check is + * performed during runtime in the output port implementation. */ + + /* for DEEPCLONE we need to check that the type of the objects being + * written to the output port is stable. */ + if (element.getConnectionMode() != FlexotaskConnectionMode.BYREF) { + FlexotaskPortTemplate inputPort = element.getInput().getOutputPort(element.getInputPortToWrite()); + + try { + Class clazz = Class.forName(inputPort.getPortType(), false, context.getClassLoader()); + if (!isStable(clazz)) + addTypeRuleViolation(Severity.ERROR, "The class '" + inputPort.getPortType() + "' used by a task port for 'deep clone' or 'hybrid' semantics is not declared Stable as required."); + } + catch (ClassNotFoundException e) { + addTypeRuleViolation(Severity.ERROR, "The class '" + inputPort.getPortType() + "' used by a task port in the Flexotask template could not be loaded."); + } + } + } mayNotAllocate = !template.isAllocating(); mayNotSynchronize = !template.isSynchronizing(); if (mayNotAllocate) { @@ -334,7 +360,12 @@ publicHeapFields = (defaultGetStaticChecking == CHECK_REF_IMMUTABLE) ? refImmutableFields : immutableFields; effectivelyFinalFields.addAll(publicHeapFields); } + + protected final void checkPortSemantics(FlexotaskTemplate template) { + + } + /** * Returns the set of type rule violations found during the validation of * the code. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-03-10 14:00:40
|
Revision: 145 http://flexotask.svn.sourceforge.net/flexotask/?rev=145&view=rev Author: jsauerbach Date: 2009-03-10 14:00:34 +0000 (Tue, 10 Mar 2009) Log Message: ----------- Adopt sourceforge's latest policy on logo display. Modified Paths: -------------- trunk/flexotask-htdocs/index.html Modified: trunk/flexotask-htdocs/index.html =================================================================== --- trunk/flexotask-htdocs/index.html 2009-02-20 13:11:59 UTC (rev 144) +++ trunk/flexotask-htdocs/index.html 2009-03-10 14:00:34 UTC (rev 145) @@ -99,7 +99,8 @@ </ul> <br><hr><br> -<a href="http://sourceforge.net"><img -src="http://sflogo.sourceforge.net/sflogo.php?group_id=242572&type=3" -width="125" height="37" border="0" alt="SourceForge.net Logo" /></a> +<a href="http://sourceforge.net/projects/flexotask"> +<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=242572&type=12" +width="120" height="30" border="0" +alt="Get Flexible Task Graphs at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a> </body> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jhs...@us...> - 2009-02-20 13:32:10
|
Revision: 144 http://flexotask.svn.sourceforge.net/flexotask/?rev=144&view=rev Author: jhspring Date: 2009-02-20 13:11:59 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Added check to ensure that class defined in flexotask task template is indeed a flexotask. See 2619862 Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/system/CodeValidator.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/system/CodeValidator.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/system/CodeValidator.java 2009-02-17 18:59:33 UTC (rev 143) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/system/CodeValidator.java 2009-02-20 13:11:59 UTC (rev 144) @@ -234,6 +234,10 @@ for (Iterator iter = template.getTasks().iterator(); iter.hasNext();) { FlexotaskTaskTemplate t = (FlexotaskTaskTemplate) iter.next(); Class c = resolveClass(t.getImplementationClass()); + if (!isFlexotask(c)) { + addClassDeclarationViolation(Severity.ERROR, c, "Class '" + c.getName() + "' used by task '" + t.getName() + "' is not a Flexotask!"); + continue; + } considerNewLiveClass(c); addMethods(c); if (isAtomicFlexotask(c)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-17 18:59:37
|
Revision: 143 http://flexotask.svn.sourceforge.net/flexotask/?rev=143&view=rev Author: jsauerbach Date: 2009-02-17 18:59:33 +0000 (Tue, 17 Feb 2009) Log Message: ----------- Add test for new scheduler diagnostic support. Modified Paths: -------------- trunk/flexotask-functiontest/src/alltests/Testcases.java Added Paths: ----------- trunk/flexotask-functiontest/src/badscheduler/ trunk/flexotask-functiontest/src/badscheduler/BadScheduler.java trunk/flexotask-functiontest/src/badscheduler/BadSchedulerRunnable.java trunk/flexotask-functiontest/src/badscheduler/Main.java Modified: trunk/flexotask-functiontest/src/alltests/Testcases.java =================================================================== --- trunk/flexotask-functiontest/src/alltests/Testcases.java 2009-02-17 18:59:04 UTC (rev 142) +++ trunk/flexotask-functiontest/src/alltests/Testcases.java 2009-02-17 18:59:33 UTC (rev 143) @@ -75,6 +75,12 @@ nativeio.Main.main(new String[0]); } + @Test + public void testBadScheduler() throws FlexotaskValidationException + { + badscheduler.Main.main(new String[0]); + } + /** * Method to test in a non-eclipse environment (e.g. a realtime VM) */ Added: trunk/flexotask-functiontest/src/badscheduler/BadScheduler.java =================================================================== --- trunk/flexotask-functiontest/src/badscheduler/BadScheduler.java (rev 0) +++ trunk/flexotask-functiontest/src/badscheduler/BadScheduler.java 2009-02-17 18:59:33 UTC (rev 143) @@ -0,0 +1,68 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package badscheduler; + +import java.util.Collections; +import java.util.Map; + +import com.ibm.realtime.flexotask.FlexotaskRunner; +import com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler; +import com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulingData; +import com.ibm.realtime.flexotask.scheduling.FlexotaskSingleThreadRunner; +import com.ibm.realtime.flexotask.scheduling.FlexotaskThreadFactory; +import com.ibm.realtime.flexotask.template.FlexotaskTemplate; +import com.ibm.realtime.flexotask.template.FlexotaskValidationException; + +/** + * A scheduler designed to misbehave in various ways to test scheduler diagnostics + */ +public class BadScheduler implements FlexotaskScheduler +{ + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler#getHeapSizes(com.ibm.realtime.flexotask.template.FlexotaskTemplate, com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulingData) + */ + @SuppressWarnings("unchecked") + public Map getHeapSizes(FlexotaskTemplate toSchedule, FlexotaskSchedulingData schedulingData) + throws FlexotaskValidationException + { + return Collections.EMPTY_MAP; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler#getRejectionReason() + */ + public String getRejectionReason() { + return ""; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler#isSchedulable(com.ibm.realtime.flexotask.template.FlexotaskTemplate, com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulingData) + */ + public boolean isSchedulable(FlexotaskTemplate toSchedule, FlexotaskSchedulingData schedulingData) { + return true; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler#schedule(com.ibm.realtime.flexotask.template.FlexotaskTemplate, java.util.Map, com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulingData, com.ibm.realtime.flexotask.scheduling.FlexotaskThreadFactory, java.util.Map) + */ + @SuppressWarnings("unchecked") + public FlexotaskRunner schedule(FlexotaskTemplate toSchedule, Map instantiationMap, FlexotaskSchedulingData schedulingData, + FlexotaskThreadFactory threadFactory, Map initializationMap) throws FlexotaskValidationException + { + int[] mode = (int[]) initializationMap.get("only"); + Runnable toRun = (Runnable) instantiationMap.get(toSchedule.getTasks().iterator().next()); + BadSchedulerRunnable runnable = new BadSchedulerRunnable(toRun, mode[0]); + return FlexotaskSingleThreadRunner.cloneAndStartThread(runnable, threadFactory); + } +} Property changes on: trunk/flexotask-functiontest/src/badscheduler/BadScheduler.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask-functiontest/src/badscheduler/BadSchedulerRunnable.java =================================================================== --- trunk/flexotask-functiontest/src/badscheduler/BadSchedulerRunnable.java (rev 0) +++ trunk/flexotask-functiontest/src/badscheduler/BadSchedulerRunnable.java 2009-02-17 18:59:33 UTC (rev 143) @@ -0,0 +1,57 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package badscheduler; + +import com.ibm.realtime.flexotask.scheduling.FlexotaskSingleThreadRunner; + +/** + * The SchedulerRunnable for BadScheduler + */ +public class BadSchedulerRunnable extends FlexotaskSingleThreadRunner +{ + private int mode; + private Runnable toRun; + + /** + * Make a new BadSchedulerRunnable + * @param toRun the Runnable to run a few times before failing + * @param mode the failure mode (see Main or read code for meanings) + */ + public BadSchedulerRunnable(Runnable toRun, int mode) { + this.toRun = toRun; + this.mode = mode; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.scheduling.FlexotaskSingleThreadRunner#runFlexotasks(boolean) + */ + public boolean runFlexotasks(boolean freshRun) { + int count = 5; + while (count-- > 0) { + toRun.run(); + nanosleep(nanoTime() + 100 * 1000 * 1000); // 100ms + } + switch (mode) { + case 0: + return true; + case 1: + int i = ((int[]) null).length; + case 2: + throw new IllegalArgumentException("voila"); + case 3: + long l = new Long(6); + } + return false; + } +} Property changes on: trunk/flexotask-functiontest/src/badscheduler/BadSchedulerRunnable.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask-functiontest/src/badscheduler/Main.java =================================================================== --- trunk/flexotask-functiontest/src/badscheduler/Main.java (rev 0) +++ trunk/flexotask-functiontest/src/badscheduler/Main.java 2009-02-17 18:59:33 UTC (rev 143) @@ -0,0 +1,141 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package badscheduler; + +import java.util.HashMap; +import java.util.Map; + +import com.ibm.realtime.flexotask.Flexotask; +import com.ibm.realtime.flexotask.FlexotaskGraph; +import com.ibm.realtime.flexotask.FlexotaskInputPort; +import com.ibm.realtime.flexotask.FlexotaskOutputPort; +import com.ibm.realtime.flexotask.FlexotaskRunner; +import com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler; +import com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulerFactory; +import com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulerRegistry; +import com.ibm.realtime.flexotask.template.FlexotaskTaskTemplate; +import com.ibm.realtime.flexotask.template.FlexotaskTemplate; +import com.ibm.realtime.flexotask.template.FlexotaskValidationException; +import com.ibm.realtime.flexotask.util.SimulationSupport; + +/** + * Tests latest support for diagnosing schedulers that fail. + */ +public class Main +{ + public static void main(String[] args) throws FlexotaskValidationException { + /* Set up bad scheduler factory */ + FlexotaskSchedulerRegistry.registerScheduler(new FlexotaskSchedulerFactory(){ + public String getName() { + return "bad"; + } + public FlexotaskScheduler getSchedulerInstance() { + return new BadScheduler(); + } + }); + /* Make single task template for testing */ + FlexotaskTemplate template = new FlexotaskTemplate(); + FlexotaskTaskTemplate task = new FlexotaskTaskTemplate(); + task.setName("only"); + task.setImplementationClass(NullFlexotask.class.getName()); + template.getTasks().add(task); + /* Set up to run the same template successively in different failure modes. The mode is indicated to the scheduler + * via the parameter passed to the only task + */ + int[] mode = new int[1]; + Map<String,Object> parameters = new HashMap<String,Object>(); + parameters.put("only", mode); + /* In mode 0, the scheduler runs the task for a few seconds but doesn't fail */ + FlexotaskGraph graph = template.validate("bad", parameters); + graph.getRunner().start(); + try { Thread.sleep(2000); } catch(InterruptedException e) {} + FlexotaskRunner runner = graph.getRunner(); + if (runner != null) { + graph.getRunner().shutdown(); + } + if (graph.getException() != null) { + throw new IllegalStateException("Unexpected exception in mode 0", graph.getException()); + } + /* In mode 1, the scheduler fails with a NullPointerException, simulating some programming mistake */ + mode[0] = 1; + graph = template.validate("bad", parameters); + graph.getRunner().start(); + try { Thread.sleep(2000); } catch(InterruptedException e) {} + runner = graph.getRunner(); + if (runner != null) { + graph.getRunner().shutdown(); + } + Throwable ex = graph.getException(); + if (ex == null) { + throw new IllegalStateException("Scheduler failed to fail in mode 1"); + } + if (!(ex instanceof NullPointerException)) { + throw new IllegalStateException("Unexpected exception type " + ex.getClass().getName() + " in mode 1"); + } + /* In mode 2, the scheduler throws IllegalArgumentException with message "voila", simulating the scheduler finding some + * terminal violation of its assumptions */ + mode[0] = 2; + graph = template.validate("bad", parameters); + graph.getRunner().start(); + try { Thread.sleep(2000); } catch(InterruptedException e) {} + runner = graph.getRunner(); + if (runner != null) { + graph.getRunner().shutdown(); + } + ex = graph.getException(); + if (ex == null) { + throw new IllegalStateException("Scheduler failed to fail in mode 2"); + } + if (!(ex instanceof IllegalArgumentException)) { + throw new IllegalStateException("Unexpected exception type " + ex.getClass().getName() + " in mode 2"); + } + if (!"voila".equals(ex.getMessage())) { + throw new IllegalStateException("Unexpected exception message '" + ex.getMessage() + "' in mode 2"); + } + /* In mode 3, the scheduler "accidentally" allocates something, causing an IllegalStateException to be issued + * from a controller or driver at the next memory switch. The bad class should be java.lang.Long. */ + if (SimulationSupport.isSimulating()) { + System.err.println("Skipping mode 3 test because not running in a real time VM"); + return; + } + mode[0] = 3; + graph = template.validate("bad", parameters); + graph.getRunner().start(); + try { Thread.sleep(2000); } catch(InterruptedException e) {} + runner = graph.getRunner(); + if (runner != null) { + graph.getRunner().shutdown(); + } + ex = graph.getException(); + if (ex == null) { + throw new IllegalStateException("Scheduler failed to fail in mode 3"); + } + if (!(ex instanceof IllegalStateException)) { + throw new IllegalStateException("Unexpected exception type " + ex.getClass().getName() + " in mode 3"); + } + String msg = ex.getMessage(); + if (msg.indexOf(Long.class.getName()) == -1) { + throw new IllegalStateException("Unexpected exception message '" + msg + "' in mode 3"); + } + } + + public static class NullFlexotask implements Flexotask + { + public void execute() {} + @SuppressWarnings("unchecked") + public void initialize(FlexotaskInputPort[] inputPorts, FlexotaskOutputPort[] outputPorts, Object parameter) { + } + } + +} Property changes on: trunk/flexotask-functiontest/src/badscheduler/Main.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-17 18:59:11
|
Revision: 142 http://flexotask.svn.sourceforge.net/flexotask/?rev=142&view=rev Author: jsauerbach Date: 2009-02-17 18:59:04 +0000 (Tue, 17 Feb 2009) Log Message: ----------- Fool with builder order in an attempt to ensure that the debug.zip gets reliably rebuilt after code changes. This still does not always seem to happen for reasons that baffle me. Modified Paths: -------------- trunk/flexotask/.project Modified: trunk/flexotask/.project =================================================================== --- trunk/flexotask/.project 2009-02-17 12:07:52 UTC (rev 141) +++ trunk/flexotask/.project 2009-02-17 18:59:04 UTC (rev 142) @@ -22,21 +22,21 @@ </buildCommand> <buildCommand> <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> - <triggers>full,incremental,</triggers> + <triggers>auto,full,incremental,</triggers> <arguments> <dictionary> <key>LaunchConfigHandle</key> - <value><project>/.externalToolBuilders/MakeDebugZip.launch</value> + <value><project>/.externalToolBuilders/UpdateDocumentation.launch</value> </dictionary> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> - <triggers>auto,full,incremental,</triggers> + <triggers>full,incremental,</triggers> <arguments> <dictionary> <key>LaunchConfigHandle</key> - <value><project>/.externalToolBuilders/UpdateDocumentation.launch</value> + <value><project>/.externalToolBuilders/MakeDebugZip.launch</value> </dictionary> </arguments> </buildCommand> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-17 12:07:56
|
Revision: 141 http://flexotask.svn.sourceforge.net/flexotask/?rev=141&view=rev Author: jsauerbach Date: 2009-02-17 12:07:52 +0000 (Tue, 17 Feb 2009) Log Message: ----------- Better diagnostics for failing scheduler, part 1. Also finish committing changes for vmBridge versioning and fine-tuning the priority setting. 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/FlexotaskSystemSupport.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/system/ConnectionDriverImpl.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/system/ConnectionDriverImpl.java 2009-02-17 12:06:34 UTC (rev 140) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/system/ConnectionDriverImpl.java 2009-02-17 12:07:52 UTC (rev 141) @@ -217,6 +217,10 @@ */ private void copyOrMove(Object inObj) { long oldSpace = FlexotaskSystemSupport.switchMemorySpace(output); + if (oldSpace == 0L) { + Class illegal = FlexotaskSystemSupport.getIllegalAllocationClass(); + throw new IllegalStateException("Scheduler allocated object of type " + illegal.getName()); + } Object outObj; if (modeIndex == FlexotaskConnectionMode.BYREF_INDEX) { outObj = inObj; Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskControllerImpl.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskControllerImpl.java 2009-02-17 12:06:34 UTC (rev 140) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskControllerImpl.java 2009-02-17 12:07:52 UTC (rev 141) @@ -84,7 +84,8 @@ try { oldSpace = FlexotaskSystemSupport.switchMemorySpace(root); if (oldSpace == 0L) { - throw new IllegalStateException(taskName); + Class illegal = FlexotaskSystemSupport.getIllegalAllocationClass(); + throw new IllegalStateException("Scheduler allocated object of type " + illegal.getName()); } root.getTask().execute(); FlexotaskSystemSupport.resetTransient(); Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskSystemSupport.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskSystemSupport.java 2009-02-17 12:06:34 UTC (rev 140) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskSystemSupport.java 2009-02-17 12:07:52 UTC (rev 141) @@ -26,6 +26,7 @@ import com.ibm.realtime.flexotask.util.ESystem; import com.ibm.realtime.flexotask.vm.FlexotaskRoot; import com.ibm.realtime.flexotask.vm.FlexotaskVMBridge; +import com.ibm.realtime.flexotask.vm.FlexotaskVMBridge1; /* * (c) Copyright IBM Corp. 2006 - 2008 All Rights Reserved @@ -62,6 +63,12 @@ static FlexotaskVMBridge vmBridge; /** + * Pointer to native system support at version 1. This will be set only if vmBridge is set, but, if the VM provides only + * version 0 support, then vmBridge will be non-null but vmBridge1 will be null. + */ + static FlexotaskVMBridge1 vmBridge1; + + /** * Flag indicating that this VM implements System.nanoTime. That we do not simply assume it * is an artifact of the current state of the J2SE and J2ME builds that we would like to support * and isn't to be considered a long-term solution. @@ -123,6 +130,17 @@ } /** + * @return the first Class that was illegally allocated by a scheduler thread or null if the + * calling thread isn't a scheduler thread or didn't illegally allocate + */ + public static Class getIllegalAllocationClass() { + if (vmBridge1 != null) { + return vmBridge1.getIllegalAllocationClass(); + } + return null; + } + + /** * Test whether running in an flexotask-enabled VM * @return true if running in an flexotask-enabled VM. */ @@ -178,17 +196,21 @@ } /** - * Cause the current thread to adopt the RT priority expressed by the priority argument (which should be in the RTSJ - * range 1-28). Mapping from these priorities to OS priorities is up to the VM provider; if the VM also supports RTSJ, - * the mapping should be the same as for RTSJ PriorityParameter objects, even though this interface currently does - * not use those objects + * Cause the current thread to adopt the RT priority expressed by the priority argument. The scale of this argument + * is adjusted so that 0 is the default, positive priorities are higher than the default, and negative priorities are + * lower than the default. In any RTSJ system, 0 is aligned with PriorityScheduler.maxPriority() and at least the + * values -27..0 are available, with priorities -N..0 being aligned to the priorities available to real time threads. + * In WebSphere Real Time, priorities -39..10 are available, and map to the odd numbered Linux SCHED_FIFO priorities + * from 1 to 99. In general, the mapping is up to the VM provider constrained only by the requirement for alignment + * with the RTSJ priorities if RTSJ is provided. * @param priority the priority to adopt + * @return true iff priority actually changed, false if unable to change */ - static void adoptPriority(int priority) { - // TODO should there be an error indication if this doesn't work? - if (vmBridge != null) { - vmBridge.adoptPriority(priority); - } // else do nothing + static boolean adoptPriority(int priority) { + if (vmBridge1 != null) { + return vmBridge1.adoptPriority(priority); + } + return false; } /** @@ -534,6 +556,9 @@ public boolean register(Service.Implementation implementation) { vmBridge = (FlexotaskVMBridge) implementation; + if (implementation instanceof FlexotaskVMBridge1) { + vmBridge1 = (FlexotaskVMBridge1) implementation; + } return true; } }.load(FlexotaskVMBridge.class); @@ -596,7 +621,7 @@ return false; } - /** + /** * Effective worker routine for isOfLegalClasses. Note: the current implementation is * recursive which is potentially problematic in terms of stack usage. However, it * does work correctly on cyclic object graphs by checking whether objects have already This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-17 12:06:39
|
Revision: 140 http://flexotask.svn.sourceforge.net/flexotask/?rev=140&view=rev Author: jsauerbach Date: 2009-02-17 12:06:34 +0000 (Tue, 17 Feb 2009) Log Message: ----------- Fine-tune priority setting; allow positive values if the underlying VM allows them. Print message if priority setting fails but (at least for now) don't fail the scheduler. Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSchedulerRunnable.java trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskThreadFactoryImpl.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSchedulerRunnable.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSchedulerRunnable.java 2009-02-17 12:05:16 UTC (rev 139) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSchedulerRunnable.java 2009-02-17 12:06:34 UTC (rev 140) @@ -28,11 +28,11 @@ private int priority; /** - * Returns the priority at which this Runnable will run, using an artificial scale in which 0 is the highest and - * default priority, and lower priorities are indicated by negative numbers. - * A non-RTSJ VM must provide at least 10 distinct levels (from 0, highest, to -9, lowest). - * An RTSJ VM must align priority 0 with PriorityScheduler.maxPriority() and (negative) priority N with - * Priority.maxPriority() + N. + * Returns the priority at which this Runnable will run, using an artificial scale in which 0 is the default and + * corresponds to PriorityScheduler.maxPriority() on an RTSJ-providing VM (on a real time VM that does not support + * RTSJ, the default is up to the VM provider but should be similar in spirit to the previous). On an RTSJ-providing + * VM, negative priorities map to Priority.maxPriority() + N down to Priority.minPriority(). Whether priorities outside + * that range (including positive ones) are allowed is up to the VM-provider. * @return the requested priority */ public int getPriority() { @@ -58,18 +58,14 @@ } /** - * Sets the priority at which this Runnable will run, using an artificial scale in which 0 is the highest and - * default priority, and lower priorities are indicated by negative numbers. - * A non-RTSJ VM must provide at least 10 distinct levels (from 0, highest, to -9, lowest). Priorities lower - * that -9 are not guaranteed to be portably distinct but are accepted. - * An RTSJ VM must align priority 0 with PriorityScheduler.maxPriority() and (negative) priority N with - * Priority.maxPriority() + N. - * @param priority the new priority, which must be <= 0 + * Sets the priority at which this Runnable will run, using an artificial scale in which 0 is the default and + * corresponds to PriorityScheduler.maxPriority() on an RTSJ-providing VM (on a real time VM that does not support + * RTSJ, the default is up to the VM provider but should be similar in spirit to the previous). On an RTSJ-providing + * VM, negative priorities map to Priority.maxPriority() + N down to Priority.minPriority(). Whether priorities outside + * that range (including positive ones) are allowed is up to the VM-provider. + * @param priority the new priority */ public void setPriority(int priority) { - if (priority > 0) { - throw new IllegalArgumentException("Priority must be <= 0"); - } this.priority = priority; } Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskThreadFactoryImpl.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskThreadFactoryImpl.java 2009-02-17 12:05:16 UTC (rev 139) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskThreadFactoryImpl.java 2009-02-17 12:06:34 UTC (rev 140) @@ -18,6 +18,7 @@ import com.ibm.realtime.flexotask.scheduling.FlexotaskThreadFactory; import com.ibm.realtime.flexotask.tracing.FlexotaskTracerFactory; import com.ibm.realtime.flexotask.tracing.FlexotaskTracerFactory.ThreadContext; +import com.ibm.realtime.flexotask.util.ESystem; /** * The concrete implementation of FlexotaskThreadFactory @@ -159,7 +160,9 @@ threadContext.activate(); FlexotaskSystemSupport.switchMemorySpace(target); FlexotaskSystemSupport.becomeFlexotaskThread(true); - FlexotaskSystemSupport.adoptPriority(target.getPriority()); + if (!FlexotaskSystemSupport.adoptPriority(target.getPriority())) { + ESystem.err.println("Warning: priority unchanged on scheduler runnable"); + } try { target.run(); } catch(Throwable t) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-17 12:05:21
|
Revision: 139 http://flexotask.svn.sourceforge.net/flexotask/?rev=139&view=rev Author: jsauerbach Date: 2009-02-17 12:05:16 +0000 (Tue, 17 Feb 2009) Log Message: ----------- Establish versioning for the VM bridge so that the Flexotask system can evolve while still supporting VM-providers who use an older specification. Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge.java Added Paths: ----------- trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge1.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge.java 2009-02-16 21:06:02 UTC (rev 138) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge.java 2009-02-17 12:05:16 UTC (rev 139) @@ -22,15 +22,15 @@ * Define the methods that bridge between the Flexotask Java support and the underlying support that must * be present in the VM. The development-time VM need not contain an implementation, since the functions * will then be simulated. However, to achieve realtime behavior an implementation must be provided. + * This version of the interface is "version 0" which defines the requirements on the VM as of Flexotask 2.0.0. + * The expectation is that new functions will be added by defining new interfaces that extend this one. */ public interface FlexotaskVMBridge extends Service.Implementation { /** Indicator passed to createMemorySpace to indicate a "normal" flexotask space */ public static final int NORMAL_MEMORY = 0; /** Indicator passed to createMemorySpace to indicate the scheduler heap */ public static final int SCHEDULER_MEMORY = 1; - /** @see FlexotaskSystemSupport#adoptPriority(int) */ - void adoptPriority(int priority); - /** @see FlexotaskSystemSupport#allocateStablePrimitiveArray(Class, int, StableArrayImpl) */ + /** @see FlexotaskSystemSupport#allocateStablePrimitiveArray(Class, int, StableArrayImpl) */ Object allocateStablePrimitiveArray(Class type, int size); /** @see FlexotaskSystemSupport#becomeFlexotaskThread(boolean) */ void becomeFlexotaskThread(boolean state); @@ -152,6 +152,6 @@ long startTransaction(Object target); /** @see FlexotaskSystemSupport#switchMemorySpace(Object) */ long switchMemorySpace(Object target); - /** @see FlexotaskSystemSupport#unpin(Object[]) */ + /** @see FlexotaskSystemSupport#unpin(Object[]) */ void unpin(Object[] objects); } Added: trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge1.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge1.java (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge1.java 2009-02-17 12:05:16 UTC (rev 139) @@ -0,0 +1,24 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.vm; + +/** + * Functions added to FlexotaskVMBridge after the release of Flexotask 2.0.0 and before the next release thereafter. + */ +public interface FlexotaskVMBridge1 extends FlexotaskVMBridge { + /** @see FlexotaskSystemSupport#adoptPriority */ + public boolean adoptPriority(int newPriority); + /** @see FlexotaskSystemSupport#getIllegalAllocationClass */ + public Class getIllegalAllocationClass(); +} Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge1.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-16 21:06:07
|
Revision: 138 http://flexotask.svn.sourceforge.net/flexotask/?rev=138&view=rev Author: jsauerbach Date: 2009-02-16 21:06:02 +0000 (Mon, 16 Feb 2009) Log Message: ----------- Support the reactive scheduler with a timing grammar and editor support. Expand the nativeio testcase to meaningfully test this scheduler. Modified Paths: -------------- trunk/flexotask/META-INF/MANIFEST.MF trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunner.java trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveScheduler.java trunk/flexotask-editor/META-INF/MANIFEST.MF trunk/flexotask-editor/plugin.xml trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/ModelElement.java trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/TaskDiagram.java trunk/flexotask-functiontest/src/alltests/Testcases.java trunk/flexotask-functiontest/src/nativeio/Main.java Added Paths: ----------- trunk/flexotask/src/com/ibm/realtime/flexotask/ClockTask.java trunk/flexotask/src/com/ibm/realtime/flexotask/FileDescriptor.java trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/package.html trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ClockAnnotation.java trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ReactiveTiming.java trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ReactiveTimingDataParser.java trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/package.html trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ClockAnnotator.java trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ReactiveGlobalTiming.java trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ReactiveGrammarProvider.java trunk/flexotask-functiontest/src/nativeio/Reactive.ftg trunk/flexotask-functiontest/src/nativeio/Reporter.java trunk/flexotask-functiontest/src/nativeio/TestReader.java Removed Paths: ------------- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveTaskParameter.java Modified: trunk/flexotask/META-INF/MANIFEST.MF =================================================================== --- trunk/flexotask/META-INF/MANIFEST.MF 2009-02-16 21:04:53 UTC (rev 137) +++ trunk/flexotask/META-INF/MANIFEST.MF 2009-02-16 21:06:02 UTC (rev 138) @@ -9,9 +9,11 @@ com.ibm.realtime.flexotask.cloning, com.ibm.realtime.flexotask.distribution, com.ibm.realtime.flexotask.scheduling, + com.ibm.realtime.flexotask.scheduling.reactive, com.ibm.realtime.flexotask.scheduling.simple, com.ibm.realtime.flexotask.template, com.ibm.realtime.flexotask.timing, + com.ibm.realtime.flexotask.timing.reactive, com.ibm.realtime.flexotask.timing.simple, com.ibm.realtime.flexotask.tools, com.ibm.realtime.flexotask.tracing, Added: trunk/flexotask/src/com/ibm/realtime/flexotask/ClockTask.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/ClockTask.java (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/ClockTask.java 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,45 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask; + +/** + * A simple TimeAware Flexotask that emits the "current time" (as reflected by the supplied + * FlexotaskTimer) on its single output port. To be useful, this task must be scheduled in + * a timing grammar that understands the semantic context. + */ +public class ClockTask implements TimeAware, Flexotask { + private FlexotaskTimer timer; + private FlexotaskOutputPort outputPort; + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.TimeAware#setTimer(com.ibm.realtime.flexotask.FlexotaskTimer) + */ + public void setTimer(FlexotaskTimer timer) { + this.timer = timer; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.Flexotask#execute() + */ + public void execute() { + outputPort.setValue(Long.valueOf(timer.nanoTime())); + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.Flexotask#initialize(com.ibm.realtime.flexotask.FlexotaskInputPort[], com.ibm.realtime.flexotask.FlexotaskOutputPort[], java.lang.Object) + */ + public void initialize(FlexotaskInputPort[] inputPorts, FlexotaskOutputPort[] outputPorts, Object parameter) { + outputPort = outputPorts[0]; + } +} Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/ClockTask.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask/src/com/ibm/realtime/flexotask/FileDescriptor.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/FileDescriptor.java (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/FileDescriptor.java 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,41 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask; + +/** + * A class that is useful in the context of a reactive scheduling discipline that will call a Flexotask whenever a file + * descriptor is ready. This class (which may be subclassed to provide additional information) is designed to be used + * as the Flexotask parameter (in either isolation model, since a shared reference is not required) so that the scheduler + * and the Flexotask will both know the file descriptor to be used. Appropriate use requires a timing grammar and scheduler + * that understands the intended semantics. + */ +public class FileDescriptor { + private int fileDescriptor; + + /** + * Make a new FileDescriptor object + * @param fileDescriptor the numer file descriptor wrapped by the object + */ + public FileDescriptor(int fileDescriptor) { + this.fileDescriptor = fileDescriptor; + } + + /** + * Get the numeric file descriptor wrapped by this object + * @return the intended file descriptor + */ + public int getFileDescriptor() { + return fileDescriptor; + } +} Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/FileDescriptor.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java 2009-02-16 21:04:53 UTC (rev 137) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java 2009-02-16 21:06:02 UTC (rev 138) @@ -13,25 +13,29 @@ */ package com.ibm.realtime.flexotask.scheduling.reactive; +import com.ibm.realtime.flexotask.FileDescriptor; import com.ibm.realtime.flexotask.scheduling.ConnectionDriver; import com.ibm.realtime.flexotask.scheduling.FlexotaskController; import com.ibm.realtime.flexotask.scheduling.NonAllocatingFifo; import com.ibm.realtime.flexotask.scheduling.NonAllocatingFifoElement; import com.ibm.realtime.flexotask.template.FlexotaskTemplateElement; import com.ibm.realtime.flexotask.template.FlexotaskValidationException; +import com.ibm.realtime.flexotask.timing.FlexotaskTimingData; +import com.ibm.realtime.flexotask.timing.reactive.ClockAnnotation; import com.ibm.realtime.flexotask.util.ESystem; /** * Represents one runnable element (connection or task) for the ReactiveScheduler */ public class ReactiveRunnableElement extends NonAllocatingFifoElement { + private static final boolean DEBUG = false; private FlexotaskTemplateElement templateElement; private Runnable toRun; - private ReactiveTaskParameter parameter; + private FileDescriptor parameter; private ReactiveRunnableElement[] successors; private ReactiveRunnableElement[] predecessors; private boolean moving; - private static final boolean DEBUG = false; + private long period; /** * Make a new element for a non-source task or for a connection @@ -47,18 +51,26 @@ * Make a new element for a source task, which must actually react to input * @param element the template element for this runnable element * @param toRun the Runnable for this runnable element - * @param parameter the ReactiveTaskParameter containing the file descriptor used to dispatch this runnable + * @param parameter the parameter being passed to the task. Either task must have a ClockAnnotation or this parameter + * must be a FileDescriptor * @throws FlexotaskValidationException if the parameter is null or of the wrong type */ public ReactiveRunnableElement(FlexotaskTemplateElement element, Runnable toRun, Object parameter) throws FlexotaskValidationException { this(element, toRun); - if (parameter instanceof ReactiveTaskParameter) { - this.parameter = (ReactiveTaskParameter) parameter; + if (parameter instanceof FileDescriptor ) { + this.parameter = (FileDescriptor) parameter; } else { - throw new FlexotaskValidationException("Source task " + element.getName() + - " does not have an appropriate parameter for the reactive scheduler"); + FlexotaskTimingData timing = element.getTimingData(); + if (timing instanceof ClockAnnotation) { + period = ((ClockAnnotation) timing).getPeriod(); + } else { + throw new FlexotaskValidationException("Source task " + element.getName() + + " has neither a FileDescriptor parameter nor a clock annotation; " + + "one or the other is needed for the reactive scheduler" + ); + } } } @@ -97,13 +109,21 @@ } /** - * @return the file descriptor if this is a source task or -1 if not + * @return the file descriptor if this is a source task with a file descriptor or -1 if not */ public int getFileDescriptor() { return parameter == null ? -1 : parameter.getFileDescriptor(); } /** + * Get the period (if zero, this task is not periodic) + * @return the specified period + */ + public long getPeriod() { + return period; + } + + /** * @return the template element for this element */ public FlexotaskTemplateElement getTemplate() { Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunner.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunner.java 2009-02-16 21:04:53 UTC (rev 137) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunner.java 2009-02-16 21:06:02 UTC (rev 138) @@ -22,21 +22,38 @@ * The FlexotaskRunner and FlexotaskSchedulerRunnable for the Reactive Scheduler */ public class ReactiveRunner extends FlexotaskSingleThreadRunner { - private ReactiveRunnableElement[] elements; + private ReactiveRunnableElement[] fdElements; + private ReactiveRunnableElement[] clockElements; private short[] states; + private long[] periods; + private long[] deadlines; private FlexotaskWaitSet waitSet; NonAllocatingFifo runQueue = new NonAllocatingFifo(0, ReactiveRunnableElement.class); /** * Make a ReactiveRunner from the source elements of the graph, which have the rest of the graph as successors * @param elements the elements to use + * @param clocks the number of elements that are clocks */ - public ReactiveRunner(ReactiveRunnableElement[] elements) { - this.elements = elements; - this.states = new short[elements.length]; - FlexotaskFileDescriptorState[] states = new FlexotaskFileDescriptorState[elements.length]; + public ReactiveRunner(ReactiveRunnableElement[] elements, int clocks) { + fdElements = new ReactiveRunnableElement[elements.length - clocks]; + clockElements = new ReactiveRunnableElement[clocks]; + FlexotaskFileDescriptorState[] states = new FlexotaskFileDescriptorState[fdElements.length]; + this.states = new short[fdElements.length]; + periods = new long[clockElements.length]; + deadlines = new long[clockElements.length]; + int clockIndex = 0; + int fdIndex = 0; for (int i = 0; i < elements.length; i++) { - states[i] = new FlexotaskFileDescriptorState(elements[i].getFileDescriptor(), FlexotaskFileDescriptorState.READ); + ReactiveRunnableElement element = elements[i]; + int fd = element.getFileDescriptor(); + if (fd > -1) { + fdElements[fdIndex] = element; + states[fdIndex++] = new FlexotaskFileDescriptorState(fd, FlexotaskFileDescriptorState.READ); + } else { + clockElements[clockIndex] = element; + periods[clockIndex++] = element.getPeriod(); + } } waitSet = new FlexotaskWaitSet(states); } @@ -45,14 +62,29 @@ * @see com.ibm.realtime.flexotask.scheduling.FlexotaskSingleThreadRunner#runFlexotasks(boolean) */ public boolean runFlexotasks(boolean freshRun) { + if (freshRun && deadlines.length > 0) { + long time = nanoTime(); + for (int i = 0; i < deadlines.length; i++) { + deadlines[i] = time + periods[i]; + } + } /* Wait for some input */ - waitSet.wait(-1, states); + waitSet.wait(timeToNextDeadline(), states); /* Run those tasks that are ready */ for (int i = 0; i < states.length; i++) { if (states[i] != 0) { - elements[i].run(runQueue); + fdElements[i].run(runQueue); } } + if (deadlines.length > 0) { + long time = nanoTime(); + for (int i = 0; i < deadlines.length; i++) { + if (time >= deadlines[i]) { + clockElements[i].run(runQueue); + deadlines[i] = time + periods[i]; + } + } + } /* Run the successors until quiescent */ ReactiveRunnableElement element = (ReactiveRunnableElement) runQueue.getFirst(); while (element != null) { @@ -62,4 +94,25 @@ } return false; } + + /** + * @return the number of nanoseconds until the next deadline, or -1 if there are no clocks or 0 if one or more deadlines have + * passed + */ + private long timeToNextDeadline() { + if (deadlines.length == 0) { + return -1; + } + long time = nanoTime(); + long ans = Long.MAX_VALUE; + for (int i = 0; i < deadlines.length; i++) { + if (time > deadlines[i]) { + return 0; + } + if (deadlines[i] < ans) { + ans = deadlines[i]; + } + } + return ans - time; + } } Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveScheduler.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveScheduler.java 2009-02-16 21:04:53 UTC (rev 137) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveScheduler.java 2009-02-16 21:06:02 UTC (rev 138) @@ -28,6 +28,8 @@ import com.ibm.realtime.flexotask.template.FlexotaskTaskTemplate; import com.ibm.realtime.flexotask.template.FlexotaskTemplate; import com.ibm.realtime.flexotask.template.FlexotaskValidationException; +import com.ibm.realtime.flexotask.timing.FlexotaskGlobalTimingData; +import com.ibm.realtime.flexotask.timing.reactive.ReactiveTiming; /** * Defines a reactive scheduler that works with any non-cyclic graph regardless of timing @@ -35,18 +37,28 @@ * as its parameter */ public class ReactiveScheduler extends AbstractScheduler { + private String rejectionReason = ""; + /* (non-Javadoc) * @see com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler#getRejectionReason() */ public String getRejectionReason() { - return "Unknown error"; + return rejectionReason; } /* (non-Javadoc) * @see com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler#isSchedulable(com.ibm.realtime.flexotask.template.FlexotaskTemplate, com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulingData) */ public boolean isSchedulable(FlexotaskTemplate toSchedule, FlexotaskSchedulingData schedulingData) { - return true; + /* We cannot check everything here because we do not have the instantiation map. Consequently, all we check for is + * the timing grammar + */ + FlexotaskGlobalTimingData timing = toSchedule.getTimingData(); + if (timing instanceof ReactiveTiming) { + return true; + } + rejectionReason = "Graph does not use the reactive timing grammar"; + return false; } /* (non-Javadoc) @@ -82,14 +94,19 @@ if (reactiveTasks.size() == 0) { throw new FlexotaskValidationException("No reactive tasks, graph must be cyclic"); } - /* From each reactive task, record all successors, recursively */ + /* From each reactive task, record all successors, recursively. Also count the number of clock tasks */ + int nClocks = 0; for (Iterator iterator = reactiveTasks.iterator(); iterator.hasNext();) { ReactiveRunnableElement element = (ReactiveRunnableElement) iterator.next(); + if (element.getPeriod() > 0) { + nClocks++; + } recordSuccessors(element, toSchedule, elementMap, new ArrayList()); } /* The resulting structure is the core of the Runner */ ReactiveRunner toRun = - new ReactiveRunner((ReactiveRunnableElement[]) reactiveTasks.toArray(new ReactiveRunnableElement[reactiveTasks.size()])); + new ReactiveRunner((ReactiveRunnableElement[]) reactiveTasks.toArray(new ReactiveRunnableElement[reactiveTasks.size()]), + nClocks); return FlexotaskSingleThreadRunner.cloneAndStartThread(toRun, threadFactory); } Deleted: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveTaskParameter.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveTaskParameter.java 2009-02-16 21:04:53 UTC (rev 137) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveTaskParameter.java 2009-02-16 21:06:02 UTC (rev 138) @@ -1,21 +0,0 @@ -/* - * This file is part of Flexible Task Graphs - * (http://sourceforge.net/projects/flexotasks) - * - * Copyright (c) 2006 - 2008 IBM Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - */ -package com.ibm.realtime.flexotask.scheduling.reactive; - -/** - * Interface to be implemented by parameters passed to source tasks when using the reactive scheduler - */ -public interface ReactiveTaskParameter { - int getFileDescriptor(); -} Added: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/package.html =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/package.html (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/package.html 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,5 @@ +<body> +Provides a reactive scheduler, which schedules "source" tasks (those with no inputs) based either on +time or on the readiness of a file descriptor, and then schedules dependent tasks based on availability +of data. Graphs must be acyclic. +</body> Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/package.html ___________________________________________________________________ Added: svn:mime-type + text/html Added: svn:eol-style + native Added: trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ClockAnnotation.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ClockAnnotation.java (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ClockAnnotation.java 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,58 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.timing.reactive; + +import com.ibm.realtime.flexotask.timing.FlexotaskTimingData; +import com.ibm.realtime.flexotask.timing.FlexotaskTimingDataParser; + +/** + * The reactive grammer permits source tasks (those with no input ports) to be declared as clocks. These have an output port + * of type Long on which time can be sent. The clock task is called by the reactive scheduler on a time-periodic basis even + * though the rest of the graph is scheduled reactively. It is as if there were an external clock being read in the same way + * that file descriptors are read, even though that is not actually what is happening. + */ +public class ClockAnnotation extends FlexotaskTimingData { + private long period; + + /** + * Make a new ClockAnnotation + * @param period the period to use + */ + public ClockAnnotation(long period) { + this.period = period; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.timing.FlexotaskTimingData#generateSource() + */ + public String generateSource() { + return new StringBuffer().append("new ").append(ClockAnnotation.class.getName()).append("(") + .append(period).append("L)").toString(); + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.timing.FlexotaskTimingData#generateXML() + */ + public String generateXML() { + StringBuilder ans = new StringBuilder("<Timing period='").append(FlexotaskTimingDataParser.formatTime(period)); + return ans.append("'/>").toString(); + } + + /** + * @return the period in nanoseconds + */ + public long getPeriod() { + return period; + } +} Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ClockAnnotation.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ReactiveTiming.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ReactiveTiming.java (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ReactiveTiming.java 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,58 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.timing.reactive; + +import com.ibm.realtime.flexotask.template.FlexotaskTemplate; +import com.ibm.realtime.flexotask.template.FlexotaskValidationException; +import com.ibm.realtime.flexotask.timing.FlexotaskGlobalTimingData; + +/** + * A very simple timing grammar for use with the rudimentary reactive scheduler. Permits + * some source tasks to be designated as clocks. + */ +public class ReactiveTiming extends FlexotaskGlobalTimingData { + /** + * Override to indicate that this grammar does not (yet) implement composition + * @see com.ibm.realtime.flexotask.timing.FlexotaskGlobalTimingData#completeComposition(com.ibm.realtime.flexotask.template.FlexotaskTemplate, com.ibm.realtime.flexotask.template.FlexotaskTemplate, com.ibm.realtime.flexotask.template.FlexotaskTemplate) + */ + public void completeComposition(FlexotaskTemplate composed, FlexotaskTemplate one, FlexotaskTemplate two) + throws FlexotaskValidationException + { + throw new FlexotaskValidationException("Composition not implemented"); + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.timing.FlexotaskGlobalTimingData#isComposableWith(com.ibm.realtime.flexotask.timing.FlexotaskGlobalTimingData) + */ + public boolean isComposableWith(FlexotaskGlobalTimingData partner) { + return partner instanceof ReactiveTiming; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.timing.FlexotaskTimingData#generateSource() + */ + public String generateSource() { + return new StringBuffer().append("new ").append(ReactiveTiming.class.getName()).append("()").toString(); + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.timing.FlexotaskTimingData#generateXML() + */ + public String generateXML() { + StringBuilder ans = new StringBuilder("<TimingProvider kind='reactive' parser='"); + ans.append(ReactiveTimingDataParser.class.getName()).append("'"); + addGraphicsXML(ans); + return ans.append("/>").toString(); + } +} Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ReactiveTiming.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ReactiveTimingDataParser.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ReactiveTimingDataParser.java (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ReactiveTimingDataParser.java 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,57 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.timing.reactive; + +import org.w3c.dom.Element; + +import com.ibm.realtime.flexotask.template.FlexotaskValidationException; +import com.ibm.realtime.flexotask.timing.FlexotaskGlobalTimingData; +import com.ibm.realtime.flexotask.timing.FlexotaskTimingData; +import com.ibm.realtime.flexotask.timing.FlexotaskTimingDataParser; + +/** + * An essentially trivial parser for the reactive timing grammar + */ +public class ReactiveTimingDataParser extends FlexotaskTimingDataParser { + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.timing.FlexotaskTimingDataParser#parseConnectionAnnotation(org.w3c.dom.Element, java.lang.String) + */ + public FlexotaskTimingData parseConnectionAnnotation(Element element, String locus) throws FlexotaskValidationException { + if (element == null) { + return null; + } + throw new FlexotaskValidationException("Reactive timing grammar does not accept annotations on connections"); + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.timing.FlexotaskTimingDataParser#parseGraphAnnotation(org.w3c.dom.Element) + */ + public FlexotaskGlobalTimingData parseGraphAnnotation(Element element) throws FlexotaskValidationException { + return new ReactiveTiming(); + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.timing.FlexotaskTimingDataParser#parseTaskAnnotation(org.w3c.dom.Element, java.lang.String) + */ + public FlexotaskTimingData parseTaskAnnotation(Element element, String locus) throws FlexotaskValidationException { + if (element == null) { + return null; + } + String period = element.getAttribute("period"); + if (period == null || period.length() == 0) { + throw new FlexotaskValidationException("Unrecognized timing annotation for reactive grammar"); + } + return new ClockAnnotation(parseTime(period)); + } +} Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/ReactiveTimingDataParser.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/package.html =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/package.html (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/package.html 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,5 @@ +<body> +Provides a reactive timing grammar for use with the reactive scheduler. Allows "clock" tasks to +be identified and associated with a period of execution. Source tasks associated with file descriptors +are not annotated, and no annotations appear on any connections or interior tasks. +</body> Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/timing/reactive/package.html ___________________________________________________________________ Added: svn:mime-type + text/html Added: svn:eol-style + native Modified: trunk/flexotask-editor/META-INF/MANIFEST.MF =================================================================== --- trunk/flexotask-editor/META-INF/MANIFEST.MF 2009-02-16 21:04:53 UTC (rev 137) +++ trunk/flexotask-editor/META-INF/MANIFEST.MF 2009-02-16 21:06:02 UTC (rev 138) @@ -12,6 +12,7 @@ com.ibm.realtime.flexotask.editor.model, com.ibm.realtime.flexotask.editor.model.commands, com.ibm.realtime.flexotask.editor.parts, + com.ibm.realtime.flexotask.editor.timing.reactive, com.ibm.realtime.flexotask.editor.timing.simple Require-Bundle: com.ibm.realtime.flexotask.generic, com.ibm.realtime.flexotask, Modified: trunk/flexotask-editor/plugin.xml =================================================================== --- trunk/flexotask-editor/plugin.xml 2009-02-16 21:04:53 UTC (rev 137) +++ trunk/flexotask-editor/plugin.xml 2009-02-16 21:06:02 UTC (rev 138) @@ -91,4 +91,13 @@ class="com.ibm.realtime.flexotask.editor.dialogs.OpenRuntimeProvider"> </handler> </extension> + <extension + id="com.ibm.realtime.flexotask.editor.timing.reactive" + name="Reactive Timing Grammar Provider" + point="com.ibm.realtime.flexotask.editor.TimingGrammar"> + <handler + class="com.ibm.realtime.flexotask.editor.timing.reactive.ReactiveGrammarProvider" + kind="Reactive Timing"> + </handler> + </extension> </plugin> Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/ModelElement.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/ModelElement.java 2009-02-16 21:04:53 UTC (rev 137) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/ModelElement.java 2009-02-16 21:06:02 UTC (rev 138) @@ -245,6 +245,7 @@ if (labels.size() == 0) { toolTip = null; color = okColor; + firePropertyChange(COLOR_PROP, null, color); return; } toolTip = new Panel(); Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/TaskDiagram.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/TaskDiagram.java 2009-02-16 21:04:53 UTC (rev 137) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/TaskDiagram.java 2009-02-16 21:06:02 UTC (rev 138) @@ -416,7 +416,9 @@ } // Set the new value setTiming(timing); - timing.setParent(this); + if (timing != null) { + timing.setParent(this); + } // Ensure the controller knows of the new value (which may be null) if (timing != null && children.add(timing)) { firePropertyChange(CHILD_ADDED_PROP, null, timing); Added: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ClockAnnotator.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ClockAnnotator.java (rev 0) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ClockAnnotator.java 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,155 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.editor.timing.reactive; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.draw2d.Label; +import org.eclipse.ui.views.properties.IPropertyDescriptor; +import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.ui.views.properties.TextPropertyDescriptor; + +import com.ibm.realtime.flexotask.editor.model.Category; +import com.ibm.realtime.flexotask.editor.model.Connection; +import com.ibm.realtime.flexotask.editor.model.LocalTiming; +import com.ibm.realtime.flexotask.editor.model.ModelElement; +import com.ibm.realtime.flexotask.editor.model.NormalTask; +import com.ibm.realtime.flexotask.timing.FlexotaskTimingData; +import com.ibm.realtime.flexotask.timing.FlexotaskTimingDataParser; +import com.ibm.realtime.flexotask.timing.reactive.ClockAnnotation; + +/** + * LocalTiming ("annotator") for tasks that appear to have no incoming connections. These can be optionally designated as + * clocks. + */ +public class ClockAnnotator implements LocalTiming +{ + private static final String CLOCK_PERIOD_ID = "ReactiveTimingClockPeriod"; + private static final Label incomingError = new Label("Clock annotation can only appear ona source task", + ModelElement.ERROR_IMAGE); + private NormalTask task; + private ClockAnnotation annotation; + + /** + * Make a new ClockAnnotator + * @param task the task to which this annotator is attached + */ + public ClockAnnotator(NormalTask task) { + this.task = task; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.LocalTiming#getAnnotation() + */ + public FlexotaskTimingData getAnnotation() { + return annotation; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.LocalTiming#getToolTipLabels(java.util.List) + */ + public void getToolTipLabels(List<Label> labels) { + /* First check if the task has acquired any incoming connections; this could require an error indication */ + List<Connection> connections = task.getIncomingConnections(); + if (connections != null && connections.size() > 0) { + if (annotation == null) { + /* Task was never annotated, so just allow it silently ... no labels needed */ + return; + } + /* Annotation is illegal */ + labels.add(incomingError); + return; + } + Label label = new Label(ModelElement.OK_IMAGE); + if (annotation == null) { + label.setText("To be scheduled via file descriptor readiness"); + } else { + label.setText("Clock task with period " + annotation.getPeriod()); + } + labels.add(label); + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.LocalTiming#setAnnotation(com.ibm.realtime.flexotask.timing.FlexotaskTimingData) + */ + public void setAnnotation(FlexotaskTimingData annotation) { + this.annotation = (ClockAnnotation) annotation; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue() + */ + public Object getEditableValue() { + return this; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors() + */ + public IPropertyDescriptor[] getPropertyDescriptors() { + List<IPropertyDescriptor> propertyList = new ArrayList<IPropertyDescriptor>(); + PropertyDescriptor pd = new TextPropertyDescriptor(CLOCK_PERIOD_ID, "Clock period"); + pd.setCategory(Category.BASIC_CATEGORY); + propertyList.add(pd); + return propertyList.toArray(new IPropertyDescriptor[0]); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object) + */ + public Object getPropertyValue(Object id) { + if (CLOCK_PERIOD_ID.equals(id)) { + if (annotation == null) { + return ""; + } else { + return FlexotaskTimingDataParser.formatTime(annotation.getPeriod()); + } + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object) + */ + public boolean isPropertySet(Object id) { + if (CLOCK_PERIOD_ID.equals(id)) { + return annotation != null; + } + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object) + */ + public void resetPropertyValue(Object id) { + if (CLOCK_PERIOD_ID.equals(id)) { + setAnnotation(null); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object) + */ + public void setPropertyValue(Object id, Object value) { + if (CLOCK_PERIOD_ID.equals(id)) { + if ("".equals(value)) { + setAnnotation(null); + } else { + long period = FlexotaskTimingDataParser.parseTime((String) value); + setAnnotation(new ClockAnnotation(period)); + } + } + } +} Property changes on: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ClockAnnotator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ReactiveGlobalTiming.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ReactiveGlobalTiming.java (rev 0) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ReactiveGlobalTiming.java 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,118 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.editor.timing.reactive; + +import java.util.List; + +import org.eclipse.draw2d.Label; +import org.eclipse.ui.views.properties.IPropertyDescriptor; + +import com.ibm.realtime.flexotask.editor.model.Connection; +import com.ibm.realtime.flexotask.editor.model.GlobalTiming; +import com.ibm.realtime.flexotask.editor.model.LocalTiming; +import com.ibm.realtime.flexotask.editor.model.ModelElement; +import com.ibm.realtime.flexotask.editor.model.NormalTask; +import com.ibm.realtime.flexotask.editor.model.Predicate; +import com.ibm.realtime.flexotask.timing.FlexotaskTimingData; +import com.ibm.realtime.flexotask.timing.reactive.ReactiveTiming; + +/** + * A GlobalTiming for the reactive grammar + */ +public class ReactiveGlobalTiming extends GlobalTiming +{ + private static final IPropertyDescriptor[] noDescriptors = new IPropertyDescriptor[0]; + + private static final ReactiveTiming timing = new ReactiveTiming(); + + /** + * Make a new ReactiveGlobalTiming + */ + public ReactiveGlobalTiming() { + computeToolTipAndColor(); + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.LocalTiming#getAnnotation() + */ + public FlexotaskTimingData getAnnotation() { + return timing; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.GlobalTiming#getElementAnnotator(com.ibm.realtime.flexotask.editor.model.ModelElement) + */ + public LocalTiming getElementAnnotator(ModelElement element) { + if (!(element instanceof NormalTask) || element instanceof Predicate) { + return null; + } + List<Connection> connections = ((NormalTask) element).getIncomingConnections(); + if (connections != null && connections.size() > 0) { + return null; + } + return new ClockAnnotator((NormalTask) element); + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.ModelElement#getName() + */ + public String getName() { + return "Reactive Timing"; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors() + */ + public IPropertyDescriptor[] getPropertyDescriptors() { + return noDescriptors; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object) + */ + public Object getPropertyValue(Object id) { + return null; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.ModelElement#getToolTipLabels(java.util.List) + */ + public void getToolTipLabels(List<Label> labels) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object) + */ + public boolean isPropertySet(Object id) { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object) + */ + public void resetPropertyValue(Object id) { + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.LocalTiming#setAnnotation(com.ibm.realtime.flexotask.timing.FlexotaskTimingData) + */ + public void setAnnotation(FlexotaskTimingData annotation) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object) + */ + public void setPropertyValue(Object id, Object value) { + } +} Property changes on: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ReactiveGlobalTiming.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ReactiveGrammarProvider.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ReactiveGrammarProvider.java (rev 0) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ReactiveGrammarProvider.java 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,73 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.editor.timing.reactive; + +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.IClasspathEntry; + +import com.ibm.realtime.flexotask.editor.model.GlobalTiming; +import com.ibm.realtime.flexotask.editor.model.TimingGrammarProvider; +import com.ibm.realtime.flexotask.timing.FlexotaskTimingData; +import com.ibm.realtime.flexotask.timing.FlexotaskTimingDataParser; +import com.ibm.realtime.flexotask.timing.reactive.ReactiveTimingDataParser; + +/** + * A TimingGrammarProvider for the reactive grammar. The only supported annotation is the + * clock annotation on source tasks. + */ +public class ReactiveGrammarProvider implements TimingGrammarProvider +{ + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.TimingGrammarProvider#getGlobalTiming(com.ibm.realtime.flexotask.timing.FlexotaskTimingData) + */ + public GlobalTiming getGlobalTiming(FlexotaskTimingData annotation) { + return new ReactiveGlobalTiming(); + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.TimingGrammarProvider#getLabel() + */ + public String getLabel() { + return "Reactive Timing"; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.TimingGrammarProvider#getParser() + */ + public FlexotaskTimingDataParser getParser() { + return new ReactiveTimingDataParser(); + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.TimingGrammarProvider#getTemplateClass() + */ + public Class<? extends GlobalTiming> getTemplateClass() { + return ReactiveGlobalTiming.class; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.LibraryProvider#addToClasspath(java.util.List) + */ + public void addToClasspath(List<IClasspathEntry> accumulator) throws CoreException { + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.editor.model.LibraryProvider#getDescription() + */ + public String getDescription() { + return "Reactive scheduling based on file descriptor readiness of 'source' tasks and 'clock' tasks"; + } +} Property changes on: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/timing/reactive/ReactiveGrammarProvider.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/flexotask-functiontest/src/alltests/Testcases.java =================================================================== --- trunk/flexotask-functiontest/src/alltests/Testcases.java 2009-02-16 21:04:53 UTC (rev 137) +++ trunk/flexotask-functiontest/src/alltests/Testcases.java 2009-02-16 21:06:02 UTC (rev 138) @@ -70,7 +70,7 @@ } @Test - public void testNativeIO() throws IOException + public void testNativeIO() throws IOException, SAXException, ParserConfigurationException, FlexotaskValidationException { nativeio.Main.main(new String[0]); } Modified: trunk/flexotask-functiontest/src/nativeio/Main.java =================================================================== --- trunk/flexotask-functiontest/src/nativeio/Main.java 2009-02-16 21:04:53 UTC (rev 137) +++ trunk/flexotask-functiontest/src/nativeio/Main.java 2009-02-16 21:06:02 UTC (rev 138) @@ -14,12 +14,22 @@ package nativeio; import java.io.IOException; +import java.io.InputStream; import java.lang.Thread.UncaughtExceptionHandler; +import java.util.HashMap; +import java.util.Map; -import com.ibm.realtime.flexotask.scheduling.FlexotaskFileDescriptorState; -import com.ibm.realtime.flexotask.scheduling.FlexotaskWaitSet; +import javax.xml.parsers.ParserConfigurationException; + +import org.xml.sax.SAXException; + +import com.ibm.realtime.flexotask.FileDescriptor; +import com.ibm.realtime.flexotask.FlexotaskGraph; +import com.ibm.realtime.flexotask.template.FlexotaskTemplate; +import com.ibm.realtime.flexotask.template.FlexotaskValidationException; +import com.ibm.realtime.flexotask.tools.FlexotaskXMLParser; +import com.ibm.realtime.flexotask.util.ESystem; import com.ibm.realtime.flexotask.util.NativeIO; -import com.ibm.realtime.flexotask.util.NonBlockingBuffer; /** * A unit test of the NativeIO, FlexotaskWaitSet and NonBlockingBuffer utilities @@ -30,7 +40,9 @@ static Throwable badSender = null; /* Main setup */ - public static void main(String[] args) throws IOException { + public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException, + FlexotaskValidationException + { /* Check environment ... no point in running when only simulating */ if (NativeIO.isSimulated()) { System.err.println("NativeIO test not run since native support not present"); @@ -52,9 +64,7 @@ /* Run sender, which will wait for receiver to connect */ sender.start(); /* Run receiver */ - receiverRun(); - /* Clean up sender */ - try { sender.join(); } catch (InterruptedException e) {} + receiverRun(sender); /* Handle any sender exception */ if (badSender != null) { if (badSender instanceof RuntimeException) { @@ -68,7 +78,9 @@ } /* The receiver loop */ - static void receiverRun() throws IOException { + static void receiverRun(Thread sender) + throws IOException, SAXException, ParserConfigurationException, FlexotaskValidationException + { /* Wait 1 second for sender to fire up */ try { Thread.sleep(1000); } catch (InterruptedException e) {} /* Connect to sender */ @@ -76,31 +88,24 @@ if (fd < 0) { throw new IllegalStateException("Connect rc=" + fd); } - /* Do a few blocking reads */ - readAndCheck(fd, true, 0); - readAndCheck(fd, true, 1); - readAndCheck(fd, true, 2); - /* Now do some non-blocking ones */ - readAndCheck(fd, false, 3); - readAndCheck(fd, false, 4); - readAndCheck(fd, false, 5); - /* Now do some non-blocking ones with a WaitSet */ - FlexotaskFileDescriptorState state = new FlexotaskFileDescriptorState(fd, FlexotaskFileDescriptorState.READ); - FlexotaskWaitSet waitSet = new FlexotaskWaitSet(new FlexotaskFileDescriptorState[] {state}); - readWithWaitSet(fd, waitSet, 6); - readWithWaitSet(fd, waitSet, 7); - readWithWaitSet(fd, waitSet, 8); - /* Now read remaining contents non-blockingly using NonBlockingBuffer */ - NonBlockingBuffer toRead = new NonBlockingBuffer(102); - int rc = toRead.read(fd); - while (rc >= 0 && rc < 102) { - try { Thread.sleep(200); } catch (InterruptedException e) {} - System.err.print(rc + " "); - rc = toRead.read(fd); + /* Set up the Flexotask Graph */ + InputStream stream = Main.class.getResourceAsStream("Reactive.ftg"); + FlexotaskTemplate template = FlexotaskXMLParser.parseStream(stream); + Map<String,Object> initMap = new HashMap<String,Object>(); + initMap.put("Reader", new FileDescriptor(fd)); + boolean[] stopflag = new boolean[1]; + initMap.put("Process", stopflag); + FlexotaskGraph graph = template.validate("ReactiveScheduler", initMap); + /* Run the Flexotask Graph */ + graph.getRunner().start(); + /* Clean up sender */ + try { sender.join(); } catch (InterruptedException e) {} + /* Wait some additional time to be sure graph is finished */ + while (!stopflag[0]) { + try {Thread.sleep(2); } catch (InterruptedException e) {} } - if (rc < 0) { - throw new IllegalStateException("NonBlockingBuffer.read() rc=" + fd); - } + ESystem.err.println("Shutting down"); + graph.getRunner().shutdown(); } /* The sender loop */ @@ -128,54 +133,4 @@ try { Thread.sleep(500); } catch (InterruptedException e) {} } } - - /** - * Read a file descriptor and check the value - * @param fd the fd to read - * @param blocking true if a blocking read should be used from the start, false if a non-blocking read should - * be done first before blocking - * @param check the value to check - */ - private static void readAndCheck(int fd, boolean blocking, int check) { - byte[] buffer = new byte[2]; - int rc = NativeIO.read(fd, buffer, 0, 2, blocking); - if (blocking) { - postCheck(check, buffer, rc); - } else if (rc != NativeIO.getBlockingCode()) { - throw new IllegalStateException("Non-blocking read " + check + " should have returned " + NativeIO.getBlockingCode() - + " but returned " + rc); - } else { - readAndCheck(fd, true, check); - } - } - - /** - * Subroutine to check a buffer against a value and a return code - * @param check the value that should be there - * @param buffer the buffer - * @param rc the return code - */ - private static void postCheck(int check, byte[] buffer, int rc) { - if (rc != 2) { - /* Assumes it is impossible for a two-byte write to break up ... is that true? */ - throw new IllegalStateException("Read " + check + " rc=" + rc); - } - int compare = (buffer[0] << 8) | buffer[1]; - if (compare != check) { - throw new IllegalStateException("Read got " + compare + ", should be " + check); - } - } - - /** - * Read a file descriptor non-blockingly using a WaitSet to wait for it and then check the value - * @param fd the fd to read - * @param waitSet the WaitSet to use - * @param check the value to check - */ - private static void readWithWaitSet(int fd, FlexotaskWaitSet waitSet, int check) { - byte[] buffer = new byte[2]; - waitSet.wait(-1, null); - int rc = NativeIO.read(fd, buffer, 0, 2, false); - postCheck(check, buffer, rc); - } } Added: trunk/flexotask-functiontest/src/nativeio/Reactive.ftg =================================================================== --- trunk/flexotask-functiontest/src/nativeio/Reactive.ftg (rev 0) +++ trunk/flexotask-functiontest/src/nativeio/Reactive.ftg 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,22 @@ +<FlexotaskTemplate> + <TimingProvider kind='reactive' parser='com.ibm.realtime.flexotask.timing.reactive.ReactiveTimingDataParser' graphics='85 60 362 43'/> + <Task id='Process' implementation='nativeio.Reporter' isolation='weak' graphics='60 60 495 213'> + <Input id='in0' type='java.lang.Long' isBuffered='false'/> + <Input id='in1' type='java.lang.String' isBuffered='false'/> + </Task> + <Task id='Clock' implementation='com.ibm.realtime.flexotask.ClockTask' isolation='strong' graphics='60 60 139 154'> + <Output id='out0' type='java.lang.Long' isBuffered='false'/> + <Timing period='2s'/> + </Task> + <Task id='Reader' implementation='nativeio.TestReader' isolation='strong' graphics='60 60 134 258'> + <Output id='out0' type='java.lang.String' isBuffered='false'/> + </Task> + <Connection id='Clock_Process' source='Clock' target='Process' mode='deepclone'> + </Connection> + <Connection id='Reader_Process' source='Reader' target='Process' targetPort='in1' mode='deepclone'> + </Connection> + <Allocation allow='true'></Allocation> + <Synchronization allow='true'></Synchronization> + <Stable mode='default'> + </Stable> +</FlexotaskTemplate> Added: trunk/flexotask-functiontest/src/nativeio/Reporter.java =================================================================== --- trunk/flexotask-functiontest/src/nativeio/Reporter.java (rev 0) +++ trunk/flexotask-functiontest/src/nativeio/Reporter.java 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,63 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package nativeio; + +import com.ibm.realtime.flexotask.Flexotask; +import com.ibm.realtime.flexotask.FlexotaskInputPort; +import com.ibm.realtime.flexotask.FlexotaskOutputPort; +import com.ibm.realtime.flexotask.util.ESystem; + +public class Reporter implements Flexotask +{ + private FlexotaskInputPort<java.lang.Long> in0; + private FlexotaskInputPort<java.lang.String> in1; + private long timebase; + private boolean[] stopflag; + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.Flexotask#initialize(com.ibm.realtime.flexotask.FlexotaskInputPort[], com.ibm.realtime.flexotask.FlexotaskOutputPort[], java.lang.Object) + */ + @SuppressWarnings("unchecked") + public void initialize(FlexotaskInputPort[] inputs, FlexotaskOutputPort[] outputs, Object parameter) + { + in0 = inputs[0]; + in1 = inputs[1]; + stopflag = (boolean[]) parameter; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.Flexotask#execute() + */ + public void execute() + { + Long timeObj = in0.getValue(); + String msg = in1.getValue(); + if (timeObj != null) { + long time = timeObj / 1000000; + if (timebase == 0) { + timebase = time; + } + ESystem.err.println("New time: " + (time - timebase)); + } + if (msg != null) { + ESystem.err.println(msg); + if ("Done".equals(msg)) { + stopflag[0] = true; + } + } + if (msg == null && timeObj == null) { + ESystem.err.println("Nothing to do!"); + } + } +} Property changes on: trunk/flexotask-functiontest/src/nativeio/Reporter.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask-functiontest/src/nativeio/TestReader.java =================================================================== --- trunk/flexotask-functiontest/src/nativeio/TestReader.java (rev 0) +++ trunk/flexotask-functiontest/src/nativeio/TestReader.java 2009-02-16 21:06:02 UTC (rev 138) @@ -0,0 +1,128 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package nativeio; + +import com.ibm.realtime.flexotask.FileDescriptor; +import com.ibm.realtime.flexotask.Flexotask; +import com.ibm.realtime.flexotask.FlexotaskInputPort; +import com.ibm.realtime.flexotask.FlexotaskOutputPort; +import com.ibm.realtime.flexotask.scheduling.FlexotaskFileDescriptorState; +import com.ibm.realtime.flexotask.scheduling.FlexotaskWaitSet; +import com.ibm.realtime.flexotask.util.NativeIO; +import com.ibm.realtime.flexotask.util.NonBlockingBuffer; + +public class TestReader implements Flexotask +{ + private int fd; + private FlexotaskOutputPort<java.lang.String> out0; + NonBlockingBuffer buffer; + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.Flexotask#initialize(com.ibm.realtime.flexotask.FlexotaskInputPort[], com.ibm.realtime.flexotask.FlexotaskOutputPort[], java.lang.Object) + */ + @SuppressWarnings("unchecked") + public void initialize(FlexotaskInputPort[] inputs, FlexotaskOutputPort[] outputs, Object parameter) + { + fd = ((FileDescriptor) parameter).getFileDescriptor(); + out0 = outputs[0]; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.Flexotask#execute() + */ + public void execute() + { + /* Do "rapid" tests first (these require that there be no pauses) */ + if (buffer == null) { + /* Do a few blocking reads */ + readAndCheck(fd, true, 0); + readAndCheck(fd, true, 1); + readAndCheck(fd, true, 2); + readAndCheck(fd, false, 3); + readAndCheck(fd, false, 4); + readAndCheck(fd, false, 5); + /* Now do some non-blocking ones with a WaitSet */ + FlexotaskFileDescriptorState states = new FlexotaskFileDescriptorState(fd, FlexotaskFileDescriptorState.READ); + FlexotaskWaitSet waitSet = new FlexotaskWaitSet(new FlexotaskFileDescriptorState[] {states}); + readWithWaitSet(fd, waitSet, 6); + re... [truncated message content] |
From: <jsa...@us...> - 2009-02-16 21:04:56
|
Revision: 137 http://flexotask.svn.sourceforge.net/flexotask/?rev=137&view=rev Author: jsauerbach Date: 2009-02-16 21:04:53 +0000 (Mon, 16 Feb 2009) Log Message: ----------- get rid of extra-clean as the whole philosophy of the build is different now but this script is still useful and will still be maintained Modified Paths: -------------- trunk/flexotask-features/feature-build.xml Modified: trunk/flexotask-features/feature-build.xml =================================================================== --- trunk/flexotask-features/feature-build.xml 2009-02-16 21:04:01 UTC (rev 136) +++ trunk/flexotask-features/feature-build.xml 2009-02-16 21:04:53 UTC (rev 137) @@ -4,10 +4,8 @@ 'extra.features'. The script uses the pde.ExportFeatures ant task, which runs asynchronously. No target can execute after the feature_export target in this script and new scripts cannot be run until the PDE Export operation is complete as shown by the icon on the lower right of the - eclipse window. You can also list files to be removed prior to export by listing them in 'extra.clean.' - Use of this script is not essential ... the standard PDE feature export wizard will work on this - project but any other features to be exported and any files to be cleaned on a preliminary basis - must then be done manually. + eclipse window. Use of this script is not essential ... the standard PDE feature export wizard + will work on this but any other features to be exported must then be done manually. --> <target name="setproperties"> <loadfile property="extra.features" srcfile="extra.features" failonerror="false"> @@ -18,22 +16,8 @@ </filterchain> </loadfile> <property name="extra.features" value=""/> - <loadfile property="extra.clean" srcfile="extra.clean" failonerror="false"/> - <property name="extra.clean" value=""/> <property name="flexotask.features" value="com.ibm.realtime.flexotask.feature${extra.features}"/> <echo message="Building features: ${flexotask.features}"/> - <property name="flexotask.clean" value=" - ../flexotask/flexotask.jar - ../flexotask/flexotasksrc.zip - ../flexotask-development/flexotaskdev.jar - ../flexotask-development/flexotaskdevsrc.zip - ../flexotask-editor/flexotaskEditor.jar - ../flexotask-editor/flexotaskEditorsrc.zip - ../flexotask-generic/flexotaskGeneric.jar - ../flexotask-generic/flexotaskGenericsrc.zip - ../realtime-analysis/realtimeAnalysis.jar - ../realtime-analysis/realtimeAnalysissrc.zip - ${extra.clean}"/> </target> <target name="feature_export" depends="clean,setproperties"> <pde.exportFeatures destination="latest-build" exportType="directory" @@ -42,9 +26,5 @@ <target name="clean" depends="setproperties"> <delete dir="latest-build"/> <mkdir dir="latest-build"/> - <delete verbose="true"> - <!-- The following ensures that this build is not contaminated by previous partial builds or copy-backs --> - <filelist dir="." files="${flexotask.clean}"/> - </delete> </target> </project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-16 21:04:03
|
Revision: 136 http://flexotask.svn.sourceforge.net/flexotask/?rev=136&view=rev Author: jsauerbach Date: 2009-02-16 21:04:01 +0000 (Mon, 16 Feb 2009) Log Message: ----------- Limit the depth of search for reasons when reporting an error (was seeing OutOfMemory in some cases). Perhaps there should be a recursion check here, but an absolute limit is reasonable too since no programmer is going to read through a causal chain that is longer than 10 or so items. Modified Paths: -------------- trunk/flexotask-development/src/com/ibm/realtime/flexotask/development/validation/DevtimeCodeValidator.java Modified: trunk/flexotask-development/src/com/ibm/realtime/flexotask/development/validation/DevtimeCodeValidator.java =================================================================== --- trunk/flexotask-development/src/com/ibm/realtime/flexotask/development/validation/DevtimeCodeValidator.java 2009-02-16 21:01:59 UTC (rev 135) +++ trunk/flexotask-development/src/com/ibm/realtime/flexotask/development/validation/DevtimeCodeValidator.java 2009-02-16 21:04:01 UTC (rev 136) @@ -173,7 +173,8 @@ private String getReasoning(FieldWrapper wrapper) { StringBuilder buf = new StringBuilder(); FieldState state = (FieldState) reachableFields.get(wrapper); - while (state.reason instanceof FieldWrapper) { + int limit = 10; + while (state.reason instanceof FieldWrapper && limit-- > 0) { buf.append(" That field may be on heap because "); FieldWrapper fw = (FieldWrapper) state.reason; buf.append(fw.getDefiningClass().getName()).append('.').append(fw.getName()).append(" may be on heap."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-16 21:02:02
|
Revision: 135 http://flexotask.svn.sourceforge.net/flexotask/?rev=135&view=rev Author: jsauerbach Date: 2009-02-16 21:01:59 +0000 (Mon, 16 Feb 2009) Log Message: ----------- The cache in the Long class should be exempted just like Integer and Short Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/validation/immutability-declarations Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/validation/immutability-declarations =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/validation/immutability-declarations 2009-02-14 23:43:34 UTC (rev 134) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/validation/immutability-declarations 2009-02-16 21:01:59 UTC (rev 135) @@ -2,6 +2,7 @@ ref java.lang.Throwable stackTrace full java.lang.Integer$IntegerCache cache full java.lang.Short$ShortCache cache +full java.lang.Long$LongCache cache full java.lang.Integer digits full java.lang.Integer sizeTable full java.lang.Integer DigitOnes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-14 23:43:37
|
Revision: 134 http://flexotask.svn.sourceforge.net/flexotask/?rev=134&view=rev Author: jsauerbach Date: 2009-02-14 23:43:34 +0000 (Sat, 14 Feb 2009) Log Message: ----------- Change priority numbering to be more truly independent of the specific RTSJ implementation used in the VM. Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSchedulerRunnable.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSchedulerRunnable.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSchedulerRunnable.java 2009-02-14 16:13:35 UTC (rev 133) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSchedulerRunnable.java 2009-02-14 23:43:34 UTC (rev 134) @@ -23,11 +23,17 @@ /** The FlexotaskTimerService to use for this Runnable */ private FlexotaskTimerService timer; - /** The priority (using the RTSJ scale of 1-28) at which this Runnable is to run */ - private int priority = 28; + /** The priority at which this Runnable is to run; a non-positive integer, with 0 representing + * the highest available (and default) priority. */ + private int priority; /** - * @return the priority at which this Runnable should run, using the RTSJ scale of 1-28 (default is 28 if never set) + * Returns the priority at which this Runnable will run, using an artificial scale in which 0 is the highest and + * default priority, and lower priorities are indicated by negative numbers. + * A non-RTSJ VM must provide at least 10 distinct levels (from 0, highest, to -9, lowest). + * An RTSJ VM must align priority 0 with PriorityScheduler.maxPriority() and (negative) priority N with + * Priority.maxPriority() + N. + * @return the requested priority */ public int getPriority() { return priority; @@ -52,14 +58,17 @@ } /** - * Set the priority at which this Runnable should run, using the RTSJ scale of 1-28 (default is 28 if never set). - * This method must be called prior to passing the Runnable to the thread factory. Otherwise, the call will have no - * effect. - * @param priority the new priority, which must be in the range 1-28 + * Sets the priority at which this Runnable will run, using an artificial scale in which 0 is the highest and + * default priority, and lower priorities are indicated by negative numbers. + * A non-RTSJ VM must provide at least 10 distinct levels (from 0, highest, to -9, lowest). Priorities lower + * that -9 are not guaranteed to be portably distinct but are accepted. + * An RTSJ VM must align priority 0 with PriorityScheduler.maxPriority() and (negative) priority N with + * Priority.maxPriority() + N. + * @param priority the new priority, which must be <= 0 */ public void setPriority(int priority) { - if (priority < 1 || priority > 28) { - throw new IllegalArgumentException("Priority must be in the range 1-28"); + if (priority > 0) { + throw new IllegalArgumentException("Priority must be <= 0"); } this.priority = priority; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-14 16:13:38
|
Revision: 133 http://flexotask.svn.sourceforge.net/flexotask/?rev=133&view=rev Author: jsauerbach Date: 2009-02-14 16:13:35 +0000 (Sat, 14 Feb 2009) Log Message: ----------- Add priority control to the FlexotaskThreadFactory API; the new API provides that the scheduler would call setPriority on each FlexotaskSchedulerRunnable before calling the thread factory. The default is to use the max available priority. This change unavoidably puts the head release in sourceforge out of sync with the latest available IBM Runtime Provider code from alphaworks; thus, no new public release of the open source should be made until the alphaWorks release is updated. Developers using the bleeding edge code may need to comment out the vmBridge call in FlexotaskSystemSupport until alphaWorks catches up. Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSchedulerRunnable.java trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskSystemSupport.java trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskThreadFactoryImpl.java trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSchedulerRunnable.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSchedulerRunnable.java 2009-02-13 15:22:34 UTC (rev 132) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSchedulerRunnable.java 2009-02-14 16:13:35 UTC (rev 133) @@ -22,14 +22,24 @@ { /** The FlexotaskTimerService to use for this Runnable */ private FlexotaskTimerService timer; + + /** The priority (using the RTSJ scale of 1-28) at which this Runnable is to run */ + private int priority = 28; /** - * Set the timer service. Called exactly once from the thread factory - * @param timer the new timer to set + * @return the priority at which this Runnable should run, using the RTSJ scale of 1-28 (default is 28 if never set) */ - public void setTimerService(FlexotaskTimerService timer) + public int getPriority() { + return priority; + } + + /** + * Sleep until a specified time in the nanoTime scale + * @param deadline the time in nanoseconds at which to wake up (same time scale as nanoTime) + */ + public void nanosleep(long deadline) { - this.timer = timer; + timer.nanosleep(deadline); } /** @@ -42,15 +52,19 @@ } /** - * Sleep until a specified time in the nanoTime scale - * @param deadline the time in nanoseconds at which to wake up (same time scale as nanoTime) + * Set the priority at which this Runnable should run, using the RTSJ scale of 1-28 (default is 28 if never set). + * This method must be called prior to passing the Runnable to the thread factory. Otherwise, the call will have no + * effect. + * @param priority the new priority, which must be in the range 1-28 */ - public void nanosleep(long deadline) - { - timer.nanosleep(deadline); - } + public void setPriority(int priority) { + if (priority < 1 || priority > 28) { + throw new IllegalArgumentException("Priority must be in the range 1-28"); + } + this.priority = priority; + } - /** + /** * Method to implement to gain access to a set of locks residing on the public heap (and pinned there). This is necessary if * the scheduler thread will do any synchronization, either with external threads or with other scheduler threads. * Called exactly once from the thread factory. The default implementation does nothing. @@ -59,4 +73,13 @@ public void setSchedulerLocks(Object[] locks) { } + + /** + * Set the timer service. Called exactly once from the thread factory + * @param timer the new timer to set + */ + public void setTimerService(FlexotaskTimerService timer) + { + this.timer = timer; + } } Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskSystemSupport.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskSystemSupport.java 2009-02-13 15:22:34 UTC (rev 132) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskSystemSupport.java 2009-02-14 16:13:35 UTC (rev 133) @@ -178,6 +178,20 @@ } /** + * Cause the current thread to adopt the RT priority expressed by the priority argument (which should be in the RTSJ + * range 1-28). Mapping from these priorities to OS priorities is up to the VM provider; if the VM also supports RTSJ, + * the mapping should be the same as for RTSJ PriorityParameter objects, even though this interface currently does + * not use those objects + * @param priority the priority to adopt + */ + static void adoptPriority(int priority) { + // TODO should there be an error indication if this doesn't work? + if (vmBridge != null) { + vmBridge.adoptPriority(priority); + } // else do nothing + } + + /** * Allocates a primitive array in the stable area. This is designed to be used when the transient * policy is enabled and primitive array classes are not marked stable (note that in some cases, * for example using borrowed arguments in conjunction with the preemptive atomic regions feature, @@ -625,7 +639,7 @@ return true; } - /** + /** * Called when tracing time events only. Dumps the contents of the time trace when it fills. * @param time the time value to record * @param sleep indicates that the event is a sleep event, rather than a time query Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskThreadFactoryImpl.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskThreadFactoryImpl.java 2009-02-13 15:22:34 UTC (rev 132) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskThreadFactoryImpl.java 2009-02-14 16:13:35 UTC (rev 133) @@ -132,7 +132,7 @@ */ private static class SchedulerWrapper implements Runnable { /** The actual scheduler runnable wrapped by this wrapper */ - private Runnable target; + private FlexotaskSchedulerRunnable target; /** The thread context to use for tracing */ private ThreadContext threadContext; /** The FlexotaskGraph of which this thread is a member */ @@ -146,7 +146,7 @@ * @param threadContext the context object to use for tracing * @param graph the FlexotaskGraph of which this thread is a member */ - SchedulerWrapper(Runnable target, ThreadContext threadContext, FlexotaskGraphImpl graph) + SchedulerWrapper(FlexotaskSchedulerRunnable target, ThreadContext threadContext, FlexotaskGraphImpl graph) { this.target = target; this.threadContext = threadContext; @@ -159,6 +159,7 @@ threadContext.activate(); FlexotaskSystemSupport.switchMemorySpace(target); FlexotaskSystemSupport.becomeFlexotaskThread(true); + FlexotaskSystemSupport.adoptPriority(target.getPriority()); try { target.run(); } catch(Throwable t) { Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge.java 2009-02-13 15:22:34 UTC (rev 132) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge.java 2009-02-14 16:13:35 UTC (rev 133) @@ -28,7 +28,9 @@ public static final int NORMAL_MEMORY = 0; /** Indicator passed to createMemorySpace to indicate the scheduler heap */ public static final int SCHEDULER_MEMORY = 1; - /** @see FlexotaskSystemSupport#allocateStablePrimitiveArray(Class, int, StableArrayImpl) */ + /** @see FlexotaskSystemSupport#adoptPriority(int) */ + void adoptPriority(int priority); + /** @see FlexotaskSystemSupport#allocateStablePrimitiveArray(Class, int, StableArrayImpl) */ Object allocateStablePrimitiveArray(Class type, int size); /** @see FlexotaskSystemSupport#becomeFlexotaskThread(boolean) */ void becomeFlexotaskThread(boolean state); @@ -150,6 +152,6 @@ long startTransaction(Object target); /** @see FlexotaskSystemSupport#switchMemorySpace(Object) */ long switchMemorySpace(Object target); - /** @see FlexotaskSystemSupport#unpin(Object[]) */ + /** @see FlexotaskSystemSupport#unpin(Object[]) */ void unpin(Object[] objects); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-13 15:22:41
|
Revision: 132 http://flexotask.svn.sourceforge.net/flexotask/?rev=132&view=rev Author: jsauerbach Date: 2009-02-13 15:22:34 +0000 (Fri, 13 Feb 2009) Log Message: ----------- Add a very rudimentary reactive scheduler. At present, this scheduler is used only for comparison with others and won't be exposed to end-users until it is a little more functional. Modified Paths: -------------- trunk/flexotask/src/META-INF/services/com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulerFactory trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/NonAllocatingFifo.java Added Paths: ----------- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunner.java trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveScheduler.java trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveSchedulerFactory.java trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveTaskParameter.java Modified: trunk/flexotask/src/META-INF/services/com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulerFactory =================================================================== --- trunk/flexotask/src/META-INF/services/com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulerFactory 2009-02-12 23:41:53 UTC (rev 131) +++ trunk/flexotask/src/META-INF/services/com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulerFactory 2009-02-13 15:22:34 UTC (rev 132) @@ -1,2 +1,4 @@ # Declare the TT (or "simple") scheduler com.ibm.realtime.flexotask.scheduling.simple.SimpleSchedulerFactory +# Declare the Reactive scheduler +com.ibm.realtime.flexotask.scheduling.reactive.ReactiveSchedulerFactory Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/NonAllocatingFifo.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/NonAllocatingFifo.java 2009-02-12 23:41:53 UTC (rev 131) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/NonAllocatingFifo.java 2009-02-13 15:22:34 UTC (rev 132) @@ -42,6 +42,9 @@ */ public NonAllocatingFifo(int size, Class type) { + if (size == 0) { + return; + } try { Constructor cons = type.getDeclaredConstructor(new Class[0]); cons.setAccessible(true); Added: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java 2009-02-13 15:22:34 UTC (rev 132) @@ -0,0 +1,183 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.scheduling.reactive; + +import com.ibm.realtime.flexotask.scheduling.ConnectionDriver; +import com.ibm.realtime.flexotask.scheduling.FlexotaskController; +import com.ibm.realtime.flexotask.scheduling.NonAllocatingFifo; +import com.ibm.realtime.flexotask.scheduling.NonAllocatingFifoElement; +import com.ibm.realtime.flexotask.template.FlexotaskTemplateElement; +import com.ibm.realtime.flexotask.template.FlexotaskValidationException; +import com.ibm.realtime.flexotask.util.ESystem; + +/** + * Represents one runnable element (connection or task) for the ReactiveScheduler + */ +public class ReactiveRunnableElement extends NonAllocatingFifoElement { + private FlexotaskTemplateElement templateElement; + private Runnable toRun; + private ReactiveTaskParameter parameter; + private ReactiveRunnableElement[] successors; + private ReactiveRunnableElement[] predecessors; + private boolean moving; + private static final boolean DEBUG = false; + + /** + * Make a new element for a non-source task or for a connection + * @param element the template element for this runnable element + * @param toRun the Runnable for this runnable element + */ + public ReactiveRunnableElement(FlexotaskTemplateElement element, Runnable toRun) { + this.templateElement = element; + this.toRun = toRun; + } + + /** + * Make a new element for a source task, which must actually react to input + * @param element the template element for this runnable element + * @param toRun the Runnable for this runnable element + * @param parameter the ReactiveTaskParameter containing the file descriptor used to dispatch this runnable + * @throws FlexotaskValidationException if the parameter is null or of the wrong type + */ + public ReactiveRunnableElement(FlexotaskTemplateElement element, Runnable toRun, Object parameter) + throws FlexotaskValidationException + { + this(element, toRun); + if (parameter instanceof ReactiveTaskParameter) { + this.parameter = (ReactiveTaskParameter) parameter; + } else { + throw new FlexotaskValidationException("Source task " + element.getName() + + " does not have an appropriate parameter for the reactive scheduler"); + } + } + + /** + * Add a predecessor, which is always a connection feeding one of this task's input ports. + * Connections don't have predecessors + * @param taskElement the task element + */ + public void addPredecessor(ReactiveRunnableElement connectionElement) { + if (predecessors == null) { + predecessors = new ReactiveRunnableElement[] {connectionElement}; + } else { + int oldlen = predecessors.length; + ReactiveRunnableElement[] newArray = new ReactiveRunnableElement[oldlen + 1]; + System.arraycopy(predecessors,0, newArray,0, oldlen); + predecessors = newArray; + predecessors[oldlen] = connectionElement; + } + + } + /** + * Add a successor, which is always a task connected by one hop in the forward direction. + * Connections don't have successors. + * @param taskElement the task element + */ + public void addSuccessor(ReactiveRunnableElement taskElement) { + if (successors == null) { + successors = new ReactiveRunnableElement[] {taskElement}; + } else { + int oldlen = successors.length; + ReactiveRunnableElement[] newArray = new ReactiveRunnableElement[oldlen + 1]; + System.arraycopy(successors,0, newArray,0, oldlen); + successors = newArray; + successors[oldlen] = taskElement; + } + } + + /** + * @return the file descriptor if this is a source task or -1 if not + */ + public int getFileDescriptor() { + return parameter == null ? -1 : parameter.getFileDescriptor(); + } + + /** + * @return the template element for this element + */ + public FlexotaskTemplateElement getTemplate() { + return templateElement; + } + + /** + * Used to avoid adding successors more than once (note that when there are no output ports, there will never be + * successors and this will always return false, but that is only a very minor inefficiency and won't cause incorrect + * results) + * @return true if this node already has successors + */ + public boolean hasSuccessors() { + return successors != null; + } + + /** Run this element */ + public void run(NonAllocatingFifo runQueue) { + if (toRun instanceof ConnectionDriver) { + ConnectionDriver driver = (ConnectionDriver) toRun; + if (moving) { + if (DEBUG) { + ESystem.err.print("Moving on "); + ESystem.err.println(driver.toString()); + } + driver.move(); + } else { + if (DEBUG) { + ESystem.err.print("Copying on "); + ESystem.err.println(driver.toString()); + } + driver.copy(); + } + } else { + if (predecessors != null) { + if (DEBUG) { + ESystem.err.print("Running "); + ESystem.err.print(predecessors.length); + ESystem.err.println(" predecessors"); + } + for (int i = 0; i < predecessors.length; i++) { + predecessors[i].run(runQueue); + } + } + FlexotaskController controller = (FlexotaskController) toRun; + if (DEBUG) { + ESystem.err.print("Running "); + ESystem.err.println(controller.toString()); + } + controller.run(); + controller.collect(); + } + /* Queue successors to run */ + if (successors == null) { + return; + } + for (int i = 0; i < successors.length; i++) { + ReactiveRunnableElement successor = successors[i]; + /* Check that this successor isn't already queued; if so, remove it and queue it later */ + for (ReactiveRunnableElement elem = (ReactiveRunnableElement) runQueue.getFirst(); elem != null; + elem = (ReactiveRunnableElement) elem.getNext()) + { + if (elem == successor) { + runQueue.remove(elem); + } + } + runQueue.add(successor); + } + } + + /** + * Sets this element to be a moving connection (only called on connections) + */ + public void setMoving() { + moving = true; + } +} Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunner.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunner.java (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunner.java 2009-02-13 15:22:34 UTC (rev 132) @@ -0,0 +1,65 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.scheduling.reactive; + +import com.ibm.realtime.flexotask.scheduling.FlexotaskFileDescriptorState; +import com.ibm.realtime.flexotask.scheduling.FlexotaskSingleThreadRunner; +import com.ibm.realtime.flexotask.scheduling.FlexotaskWaitSet; +import com.ibm.realtime.flexotask.scheduling.NonAllocatingFifo; + +/** + * The FlexotaskRunner and FlexotaskSchedulerRunnable for the Reactive Scheduler + */ +public class ReactiveRunner extends FlexotaskSingleThreadRunner { + private ReactiveRunnableElement[] elements; + private short[] states; + private FlexotaskWaitSet waitSet; + NonAllocatingFifo runQueue = new NonAllocatingFifo(0, ReactiveRunnableElement.class); + + /** + * Make a ReactiveRunner from the source elements of the graph, which have the rest of the graph as successors + * @param elements the elements to use + */ + public ReactiveRunner(ReactiveRunnableElement[] elements) { + this.elements = elements; + this.states = new short[elements.length]; + FlexotaskFileDescriptorState[] states = new FlexotaskFileDescriptorState[elements.length]; + for (int i = 0; i < elements.length; i++) { + states[i] = new FlexotaskFileDescriptorState(elements[i].getFileDescriptor(), FlexotaskFileDescriptorState.READ); + } + waitSet = new FlexotaskWaitSet(states); + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.scheduling.FlexotaskSingleThreadRunner#runFlexotasks(boolean) + */ + public boolean runFlexotasks(boolean freshRun) { + /* Wait for some input */ + waitSet.wait(-1, states); + /* Run those tasks that are ready */ + for (int i = 0; i < states.length; i++) { + if (states[i] != 0) { + elements[i].run(runQueue); + } + } + /* Run the successors until quiescent */ + ReactiveRunnableElement element = (ReactiveRunnableElement) runQueue.getFirst(); + while (element != null) { + element.run(runQueue); + runQueue.remove(element); + element = (ReactiveRunnableElement) element.getNext(); + } + return false; + } +} Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunner.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveScheduler.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveScheduler.java (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveScheduler.java 2009-02-13 15:22:34 UTC (rev 132) @@ -0,0 +1,135 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.scheduling.reactive; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import com.ibm.realtime.flexotask.FlexotaskRunner; +import com.ibm.realtime.flexotask.scheduling.AbstractScheduler; +import com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulingData; +import com.ibm.realtime.flexotask.scheduling.FlexotaskSingleThreadRunner; +import com.ibm.realtime.flexotask.scheduling.FlexotaskThreadFactory; +import com.ibm.realtime.flexotask.template.FlexotaskConnectionTemplate; +import com.ibm.realtime.flexotask.template.FlexotaskTaskTemplate; +import com.ibm.realtime.flexotask.template.FlexotaskTemplate; +import com.ibm.realtime.flexotask.template.FlexotaskValidationException; + +/** + * Defines a reactive scheduler that works with any non-cyclic graph regardless of timing + * annotations. Requires every task that has no incoming connections to take a ReactiveTaskParameter + * as its parameter + */ +public class ReactiveScheduler extends AbstractScheduler { + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler#getRejectionReason() + */ + public String getRejectionReason() { + return "Unknown error"; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler#isSchedulable(com.ibm.realtime.flexotask.template.FlexotaskTemplate, com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulingData) + */ + public boolean isSchedulable(FlexotaskTemplate toSchedule, FlexotaskSchedulingData schedulingData) { + return true; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler#schedule(com.ibm.realtime.flexotask.template.FlexotaskTemplate, java.util.Map, com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulingData, com.ibm.realtime.flexotask.scheduling.FlexotaskThreadFactory, java.util.Map) + */ + public FlexotaskRunner schedule(FlexotaskTemplate toSchedule, Map instantiationMap, FlexotaskSchedulingData schedulingData, + FlexotaskThreadFactory threadFactory, Map initializationMap) throws FlexotaskValidationException + { + /* Build a Map from tasks to their encasing ReactiveRunnableElements, remembering the reactive tasks as we go */ + List reactiveTasks = new ArrayList(); + Map elementMap = new HashMap(); + for (Iterator iterator = toSchedule.getTasks().iterator(); iterator.hasNext();) { + FlexotaskTaskTemplate task = (FlexotaskTaskTemplate) iterator.next(); + ReactiveRunnableElement element; + if (task.getNumberOfInputPorts() == 0) { + element = new ReactiveRunnableElement(task, (Runnable) instantiationMap.get(task), + initializationMap.get(task.getName())); + reactiveTasks.add(element); + } else { + element = new ReactiveRunnableElement(task, (Runnable) instantiationMap.get(task)); + } + elementMap.put(task, element); + } + /* Add all connections to the element map, also recording them as predecessors of their target task */ + for (Iterator iterator = toSchedule.getConnections().iterator(); iterator.hasNext();) { + FlexotaskConnectionTemplate connection = (FlexotaskConnectionTemplate) iterator.next(); + ReactiveRunnableElement element = new ReactiveRunnableElement(connection, (Runnable) instantiationMap.get(connection)); + ReactiveRunnableElement targetTask = (ReactiveRunnableElement) elementMap.get(connection.getOutput()); + targetTask.addPredecessor(element); + elementMap.put(connection, element); + } + /* Check that there is at least one reactive task */ + if (reactiveTasks.size() == 0) { + throw new FlexotaskValidationException("No reactive tasks, graph must be cyclic"); + } + /* From each reactive task, record all successors, recursively */ + for (Iterator iterator = reactiveTasks.iterator(); iterator.hasNext();) { + ReactiveRunnableElement element = (ReactiveRunnableElement) iterator.next(); + recordSuccessors(element, toSchedule, elementMap, new ArrayList()); + } + /* The resulting structure is the core of the Runner */ + ReactiveRunner toRun = + new ReactiveRunner((ReactiveRunnableElement[]) reactiveTasks.toArray(new ReactiveRunnableElement[reactiveTasks.size()])); + return FlexotaskSingleThreadRunner.cloneAndStartThread(toRun, threadFactory); + } + + /** + * Record the successors of a ReactiveRunnableElement containing a task + * @param element the element whose successors are to be calculated + * @param toSchedule the entire template, used to find connections + * @param elementMap map in which to find the scheduling element for each template element + * @param checker a list of elements used to detect cycles + * @throws FlexotaskValidationException when a cycle is detected + */ + private void recordSuccessors(ReactiveRunnableElement element, FlexotaskTemplate toSchedule, + Map elementMap, List checker) throws FlexotaskValidationException + { + /* Check for recursion */ + if (checker.contains(element)) { + throw new FlexotaskValidationException("Graph contains cycle"); + } + /* While recursion is an error, the successors of a node may already be known due to fan-in */ + if (element.hasSuccessors()) { + return; + } + checker.add(element); + /* Iterate over all outgoing connections, finding successor tasks */ + FlexotaskTaskTemplate task = (FlexotaskTaskTemplate) element.getTemplate(); + for (int i = 0; i < task.getNumberOfOutputPorts(); i++) { + Iterator connections = toSchedule.getConnectionsFrom(task, i); + while(connections.hasNext()) { + FlexotaskConnectionTemplate connection = (FlexotaskConnectionTemplate) connections.next(); + FlexotaskTaskTemplate nextTask = connection.getOutput(); + ReactiveRunnableElement nextTaskElement = (ReactiveRunnableElement) elementMap.get(nextTask); + element.addSuccessor(nextTaskElement); + /* Recursively record successors, checking for a cycle */ + recordSuccessors(nextTaskElement, toSchedule, elementMap, checker); + /* If the connection is the last from its port, make it into a moving connection */ + if (!connections.hasNext()) { + ReactiveRunnableElement connectionElement = (ReactiveRunnableElement) elementMap.get(connection); + connectionElement.setMoving(); + } + } + } + } +} Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveScheduler.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveSchedulerFactory.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveSchedulerFactory.java (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveSchedulerFactory.java 2009-02-13 15:22:34 UTC (rev 132) @@ -0,0 +1,38 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.scheduling.reactive; + +import com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler; +import com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulerFactory; + +/** + * Defines a reactive scheduler that works with any non-cyclic graph regardless of timing + * annotations. Requires every task that has no incoming connections to take a ReactiveTaskParameter + * as its parameter + */ +public class ReactiveSchedulerFactory extends FlexotaskSchedulerFactory { + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulerFactory#getName() + */ + public String getName() { + return "ReactiveScheduler"; + } + + /* (non-Javadoc) + * @see com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulerFactory#getSchedulerInstance() + */ + public FlexotaskScheduler getSchedulerInstance() { + return new ReactiveScheduler(); + } +} Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveSchedulerFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveTaskParameter.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveTaskParameter.java (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveTaskParameter.java 2009-02-13 15:22:34 UTC (rev 132) @@ -0,0 +1,21 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.scheduling.reactive; + +/** + * Interface to be implemented by parameters passed to source tasks when using the reactive scheduler + */ +public interface ReactiveTaskParameter { + int getFileDescriptor(); +} Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveTaskParameter.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-12 23:41:57
|
Revision: 131 http://flexotask.svn.sourceforge.net/flexotask/?rev=131&view=rev Author: jsauerbach Date: 2009-02-12 23:41:53 +0000 (Thu, 12 Feb 2009) Log Message: ----------- Fix some comments. Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskScheduler.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskScheduler.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskScheduler.java 2009-02-11 19:05:19 UTC (rev 130) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskScheduler.java 2009-02-12 23:41:53 UTC (rev 131) @@ -44,7 +44,7 @@ /** * Determine if an FlexotaskTemplate can be scheduled * @param toSchedule the specification to be checked. This has already been found consistent and - * type-valid by the main validator, which has also checked that no method violates exotask rules. + * type-valid by the main validator, which has also checked that no method violates Flexotask rules. * @param schedulingData information that the scheduler may need to schedule the graph but * that is not provided as timing information at graph specification time (for example, WCETs) * @return true if the specification is schedulable, false otherwise @@ -56,15 +56,18 @@ * @param toSchedule the specification to schedule. This has already been found valid by the * main validator and schedulable by this scheduler. * @param instantiationMap the map from FlexotaskTemplateElement elements within the - * specification to the actual Runnables representing those elements in the FlexotaskTemplate being + * specification to the actual Runnables representing those elements in the FlexotaskGraph being * constructed * @param schedulingData information that the scheduler may need to schedule the graph but * that is not provided as timing information within the graph (for example, WCETs) * @param threadFactory the FlexotaskThreadFactory to use in creating any threads that will * actually call the Runnables in the instantiation map. Important: these runnables may * ONLY be called by threads created by this thread factory. - * @param initializationMap the map from FlexotaskTemplateElement elements within the specification - * to the initialization parameters, one of the uses is to transfer file descriptors to trigger actors. + * @param initializationMap the map from names of elements within the specification + * to the initialization parameters, if any. Note that this map uses names as keys, not the elements. + * This allows the scheduler to inspect runtime information being + * passed to individual Flexotasks. For example, a reactive scheduler can share a file descriptor number with + * an I/O task. * @return a new FlexotaskRunner for this set of Runnables under this specification * @throws FlexotaskValidationException if a failure occurs during scheduling. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <jhs...@us...> - 2009-02-09 18:26:31
|
Revision: 129 http://flexotask.svn.sourceforge.net/flexotask/?rev=129&view=rev Author: jhspring Date: 2009-02-09 18:26:28 +0000 (Mon, 09 Feb 2009) Log Message: ----------- added support for port buffering change propagation, see 2582312 Modified Paths: -------------- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Connection.java trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/NormalTask.java Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Connection.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Connection.java 2009-02-09 17:01:13 UTC (rev 128) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Connection.java 2009-02-09 18:26:28 UTC (rev 129) @@ -95,6 +95,9 @@ /** Indicates that type information is being propagated; stops cyclic propagation if true */ private boolean propagatingType; + /** Indicates that port buffering status is being propagated; stops cyclic propagation if true */ + private boolean propagatingPortBuffering; + /** Connection's source endpoint. */ private Task source; @@ -533,6 +536,8 @@ */ public void setSourcePortBuffering(boolean value) { sourcePortBuffering = value; + propagatePortBuffering((NormalTask) source, value, sourcePortName, true); + computeToolTipAndColor(); } /** @@ -541,9 +546,22 @@ */ public void setTargetPortBuffering(boolean value) { targetPortBuffering = value; + propagatePortBuffering((NormalTask) target, value, targetPortName, false); + computeToolTipAndColor(); } /** + * Propagate a newly-set buffering status to all connections connected to that + * port + */ + private void propagatePortBuffering(NormalTask task, boolean newValue, String name, boolean isSourcePort) + { + propagatingPortBuffering = true; + task.propagatingPortBuffering(newValue, name, isSourcePort); + propagatingPortBuffering = false; + } + + /** * Sets the buffering of the source or target port of the provided task. * @param isTarget true iff it is the target port name that is changing (source otherwise) * @param task the NormalTask that is affected by the change @@ -561,6 +579,8 @@ portDecl.isBuffered = isBuffered; task.portDeclarationsChanged(); firePropertyChange(PORT_DECLARATION_CHANGED_PROP, null, portDecl); + propagatePortBuffering(task, isBuffered, portName, !isTarget); + computeToolTipAndColor(); } /** Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/NormalTask.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/NormalTask.java 2009-02-09 17:01:13 UTC (rev 128) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/NormalTask.java 2009-02-09 18:26:28 UTC (rev 129) @@ -128,6 +128,9 @@ /** True while propagating type information to stop endless cycling */ private boolean propagatingType; + /** True while propagating port buffering status to stop endless cycling */ + private boolean propagatingPortBuffering; + /** * Create a new NormalTask */ @@ -610,6 +613,31 @@ } /** + * Function to handle incoming propagation of port buffer change + * @param newValue the new value to being set + * @param portName the name of the port by which the change is being propagated + * @param isSourcePort true if the portName names a source port, false for a target port + */ + void propagatingPortBuffering(boolean newValue, String portName, boolean isSourcePort) + { + if (propagatingPortBuffering) { + return; + } + List<Connection> conns = isSourcePort ? getOutgoingConnections() : getIncomingConnections(); + propagatingPortBuffering = true; + for (Connection conn : conns) { + String match = isSourcePort ? conn.getSourcePortName() : conn.getTargetPortName(); + if (match.equals(portName)) { + if (isSourcePort) + conn.setSourcePortBuffering(newValue); + else + conn.setTargetPortBuffering(newValue); + } + } + propagatingPortBuffering = false; + } + + /** * Set the predicate property. Only called from subclass constructor * @param predicate the new value of the predicate property */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jhs...@us...> - 2009-02-09 17:01:16
|
Revision: 128 http://flexotask.svn.sourceforge.net/flexotask/?rev=128&view=rev Author: jhspring Date: 2009-02-09 17:01:13 +0000 (Mon, 09 Feb 2009) Log Message: ----------- see 2582102 Modified Paths: -------------- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/TaskDiagram.java Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/TaskDiagram.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/TaskDiagram.java 2009-02-06 21:02:44 UTC (rev 127) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/TaskDiagram.java 2009-02-09 17:01:13 UTC (rev 128) @@ -565,6 +565,9 @@ conn.setType(element.getAttribute("type")); conn.setSourcePortName(element.getAttribute("sourcePort")); conn.setTargetPortName(element.getAttribute("targetPort")); + conn.setSourcePortBuffering(Boolean.parseBoolean(element.getAttribute("sourcePortBuffering"))); + conn.setTargetPortBuffering(Boolean.parseBoolean(element.getAttribute("targetPortBuffering"))); + conn.computeToolTipAndColor(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-06 21:02:48
|
Revision: 127 http://flexotask.svn.sourceforge.net/flexotask/?rev=127&view=rev Author: jsauerbach Date: 2009-02-06 21:02:44 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Remove the VeryNullLogger class ... it is not really Flexotask-related and ended up in this codebase largely by accident. Removed Paths: ------------- trunk/flexotask-tuningfork/src/com/ibm/realtime/flexotask/tuningfork/VeryNullLogger.java Deleted: trunk/flexotask-tuningfork/src/com/ibm/realtime/flexotask/tuningfork/VeryNullLogger.java =================================================================== --- trunk/flexotask-tuningfork/src/com/ibm/realtime/flexotask/tuningfork/VeryNullLogger.java 2009-02-05 16:32:41 UTC (rev 126) +++ trunk/flexotask-tuningfork/src/com/ibm/realtime/flexotask/tuningfork/VeryNullLogger.java 2009-02-06 21:02:44 UTC (rev 127) @@ -1,202 +0,0 @@ -/* - * This file is part of Flexible Task Graphs - * (http://sourceforge.net/projects/flexotasks) - * - * Copyright (c) 2006 - 2008 IBM Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - */ -package com.ibm.realtime.flexotask.tuningfork; - -import com.ibm.tuningfork.tracegen.IBookmarkEvent; -import com.ibm.tuningfork.tracegen.IConversionFeedlet; -import com.ibm.tuningfork.tracegen.IFeedlet; -import com.ibm.tuningfork.tracegen.ILogger; -import com.ibm.tuningfork.tracegen.ITimerEvent; -import com.ibm.tuningfork.tracegen.IValueEvent; -import com.ibm.tuningfork.tracegen.types.EventType; - -/** - * A NullLogger that really really really doesn't need a ByteBuffer - */ -public class VeryNullLogger implements ILogger -{ - public void addEventType(EventType et) - { - } - - public void addProperty(String propertyName, String value) - { - } - - public int addString(String value) - { - return 0; - } - - public void close() - { - } - - public void defineHistogramFigure(String name, ITimerEvent[] events) - { - } - - public void defineOscilloscopeFigure(String name, ITimerEvent[] events) - { - } - - public void definePieChartFigure(String name, ITimerEvent[] events) - { - } - - public void defineTimeSeriesFigure(String name, IValueEvent[] values, - ITimerEvent[] intervals) - { - } - - public IBookmarkEvent makeBookmarkEvent(String name) - { - return new VeryNullBookmarkEvent(); - } - - public IFeedlet makeFeedlet(String name, String description) - { - return new VeryNullFeedlet(); - } - - public ITimerEvent makeTimerEvent(String name) - { - return new VeryNullTimerEvent(); - } - - public IValueEvent makeValueEvent(String name) - { - return new VeryNullValueEvent(); - } - - public class VeryNullBookmarkEvent implements IBookmarkEvent - { - public void addBookmark(IFeedlet feedlet, String annotation) - { - } - - public void addBookmark(String annotation) - { - } - - public String getName() - { - return null; - } - } - - public class VeryNullFeedlet implements IFeedlet - { - public void addEvent(EventType eventType) - { - } - - public void addEvent(EventType eventType, double v) - { - } - - public void addEvent(EventType eventType, int v) - { - } - - public void addEvent(EventType eventType, int[] idata, long[] ldata, - double[] ddata, String[] sdata) - { - } - - public void addEvent(EventType eventType, long v) - { - } - - public void addEvent(EventType eventType, String v) - { - } - - public void bindToCurrentThread() - { - } - - public boolean isManual() - { - return false; - } - - public boolean setTime(long timeStamp) - { - return false; - } - - public boolean recordThreadId() - { - return false; - } - - public void setThreadId(int tid) - { - } - } - - public class VeryNullTimerEvent implements ITimerEvent - { - public String getName() - { - return null; - } - - public void start() - { - } - - public void start(IConversionFeedlet feedlet, long timeStamp) - { - } - - public void start(IFeedlet feedlet) - { - } - - public void stop() - { - } - - public void stop(IConversionFeedlet feedlet, long timeStamp) - { - } - - public void stop(IFeedlet feedlet) - { - } - } - - public class VeryNullValueEvent implements IValueEvent - { - public void addValue(double value) - { - } - - public void addValue(IConversionFeedlet feedlet, long timeStamp, - double value) - { - } - - public void addValue(IFeedlet feedlet, double value) - { - } - - public String getName() - { - return null; - } - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-05 16:32:44
|
Revision: 126 http://flexotask.svn.sourceforge.net/flexotask/?rev=126&view=rev Author: jsauerbach Date: 2009-02-05 16:32:41 +0000 (Thu, 05 Feb 2009) Log Message: ----------- In NativeIO add the ability to dynamically vary between blocking and non-blocking operations on an individual socket. This commit adds the native code portion. Modified Paths: -------------- trunk/flexotask/native/NBIO.c Modified: trunk/flexotask/native/NBIO.c =================================================================== --- trunk/flexotask/native/NBIO.c 2009-02-05 16:16:39 UTC (rev 125) +++ trunk/flexotask/native/NBIO.c 2009-02-05 16:32:41 UTC (rev 126) @@ -2,7 +2,7 @@ * This file is part of Flexible Task Graphs * (http://sourceforge.net/projects/flexotasks) * - * Copyright (c) 2006 - 2008 IBM Corporation. + * Copyright (c) 2006 - 2009 IBM Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,6 +19,7 @@ #include <netinet/tcp.h> #include <fcntl.h> #include <termios.h> +#include <poll.h> /* * Class: com_ibm_realtime_flexotask_util_NativeIO @@ -31,7 +32,7 @@ { jint sock; struct sockaddr_in addr; - int rc; + int rc; if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { return -errno; } @@ -40,12 +41,12 @@ addr.sin_port = htons(port); addr.sin_addr.s_addr = 0; if (bind(sock, (struct sockaddr*)&addr, sizeof(addr)) < 0) { - rc = -errno; + rc = -errno; close(sock); return rc; } if (listen(sock, 2) < 0) { - rc = -errno; + rc = -errno; close(sock); return rc; } @@ -58,20 +59,20 @@ static int makeNonBlocking(int sock, jboolean tcp) { int flags, rc; - if (tcp) { - int on = 1; - if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof(int))) { - rc = -errno; - close(sock); - return rc; - } - } + if (tcp) { + int on = 1; + if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof(int))) { + rc = -errno; + close(sock); + return rc; + } + } flags = fcntl(sock, F_GETFL, 0); if (flags == -1) { flags = 0; } if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0) { - rc = -errno; + rc = -errno; close(sock); return rc; } @@ -81,70 +82,62 @@ /* * Class: com_ibm_realtime_flexotask_util_NativeIO * Method: doUDPlisten - * Signature: (IZ)I + * Signature: (I)I */ JNIEXPORT jint JNICALL Java_com_ibm_realtime_flexotask_util_NativeIO_doUDPlisten -(JNIEnv *env, jclass ignore, jint port, jboolean isBlocking) +(JNIEnv *env, jclass ignore, jint port) { - int rc; + int rc; struct sockaddr_in addr; - jint sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + jint sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sock < 0) { - return -errno; + return -errno; } memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); if (bind(sock, (struct sockaddr*)&addr, sizeof(addr)) < 0) { - rc = -errno; - close(sock); - return rc; - } - if (isBlocking) { - return sock; - } else { - return makeNonBlocking(sock, 0); - } + rc = -errno; + close(sock); + return rc; + } + return makeNonBlocking(sock, 0); } /* * Class: com_ibm_realtime_flexotask_util_NativeIO * Method: doAccept - * Signature: (IZ)I + * Signature: (I)I */ JNIEXPORT jint JNICALL Java_com_ibm_realtime_flexotask_util_NativeIO_doAccept -(JNIEnv * env, jclass ignore, jint socket, jboolean isBlocking) +(JNIEnv * env, jclass ignore, jint socket) { jint sock = accept(socket, NULL, 0); if (sock < 0) { return -errno; } - if (isBlocking) { - return sock; - } else { - return makeNonBlocking(sock, 1); - } + return makeNonBlocking(sock, 1); } /* * Class: com_ibm_realtime_flexotask_util_NativeIO * Method: doConnect - * Signature: (IIZZ)I + * Signature: (IIZ)I */ JNIEXPORT jint JNICALL Java_com_ibm_realtime_flexotask_util_NativeIO_doConnect -(JNIEnv * env, jclass ignore, jint host, jint port, jboolean udp, jboolean isBlocking) +(JNIEnv * env, jclass ignore, jint host, jint port, jboolean udp) { jint sock; struct sockaddr_in addr; - int rc; - if (udp) { - sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - } else { - sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - } + int rc; + if (udp) { + sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + } else { + sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + } if (sock < 0) { return -errno; } @@ -153,15 +146,11 @@ addr.sin_port = htons(port); addr.sin_addr.s_addr = htonl(host); if (connect(sock, (struct sockaddr*)&addr, sizeof(addr)) < 0) { - rc = -errno; + rc = -errno; close(sock); return rc; } - if (isBlocking) { - return sock; - } else { - return makeNonBlocking(sock, !udp); - } + return makeNonBlocking(sock, !udp); } /* @@ -173,31 +162,31 @@ Java_com_ibm_realtime_flexotask_util_NativeIO_doRs232 (JNIEnv * env, jclass ignore, jstring dev, jint baudrate) { - const char* name; - jint fd; - struct termios term; - int rc; - name = (*env)->GetStringUTFChars(env, dev, 0); - fd = open(name, O_RDWR | O_NOCTTY); - (*env)->ReleaseStringUTFChars(env, dev, name); - if (fd < 0) { - return -errno; - } - memset(&term, 0, sizeof term); - term.c_cflag = baudrate | CS8 | CLOCAL | CREAD; - term.c_iflag = IGNPAR; - term.c_cc[VTIME] = 0; // temp - if (tcflush(fd, TCIFLUSH) < 0) { - rc = -errno; - close(fd); - return rc; - } - if (tcsetattr(fd, TCSANOW, &term) < 0) { - rc = -errno; - close(fd); - return rc; - } - return fd; + const char* name; + jint fd; + struct termios term; + int rc; + name = (*env)->GetStringUTFChars(env, dev, 0); + fd = open(name, O_RDWR | O_NOCTTY); + (*env)->ReleaseStringUTFChars(env, dev, name); + if (fd < 0) { + return -errno; + } + memset(&term, 0, sizeof term); + term.c_cflag = baudrate | CS8 | CLOCAL | CREAD; + term.c_iflag = IGNPAR; + term.c_cc[VTIME] = 0; // temp + if (tcflush(fd, TCIFLUSH) < 0) { + rc = -errno; + close(fd); + return rc; + } + if (tcsetattr(fd, TCSANOW, &term) < 0) { + rc = -errno; + close(fd); + return rc; + } + return fd; } /* @@ -213,40 +202,64 @@ } /* + * Wait for a state of file descriptor readiness + */ +static int +waitForFD(int fd, short state) +{ + struct pollfd polldata; + polldata.fd = fd; + polldata.events = state; + return poll(&polldata, 1, -1); +} + +/* * Class: com_ibm_realtime_flexotask_util_NativeIO * Method: doRead - * Signature: (I[BII)I + * Signature: (I[BIIZ)I */ JNIEXPORT jint JNICALL Java_com_ibm_realtime_flexotask_util_NativeIO_doRead -(JNIEnv * env, jclass ignore, jint fd, jbyteArray buffer, jint offset, jint length) +(JNIEnv * env, jclass ignore, jint fd, jbyteArray buffer, jint offset, jint length, jboolean wait) { - int rc; - jbyte* buf = (*env)->GetByteArrayElements(env, buffer, 0); - rc = read(fd, buf+offset, length); - (*env)->ReleaseByteArrayElements(env, buffer, buf, 0); - if (rc < 0) { - rc = -errno; + int rc; + if (wait) { + rc = waitForFD(fd, POLLIN); + if (rc < 0) { + return -errno; + } } - return rc; + jbyte* buf = (*env)->GetByteArrayElements(env, buffer, 0); + rc = read(fd, buf+offset, length); + (*env)->ReleaseByteArrayElements(env, buffer, buf, 0); + if (rc < 0) { + rc = -errno; + } + return rc; } /* * Class: com_ibm_realtime_flexotask_util_NativeIO * Method: doWrite - * Signature: (I[BII)I + * Signature: (I[BIIZ)I */ JNIEXPORT jint JNICALL Java_com_ibm_realtime_flexotask_util_NativeIO_doWrite -(JNIEnv * env, jclass ignore, jint fd, jbyteArray buffer, jint offset, jint length) +(JNIEnv * env, jclass ignore, jint fd, jbyteArray buffer, jint offset, jint length, jboolean wait) { - int rc; - jbyte* buf = (*env)->GetByteArrayElements(env, buffer, 0); - rc = write(fd, buf+offset, length); - (*env)->ReleaseByteArrayElements(env, buffer, buf, 0); - if (rc < 0) { - rc = -errno; + int rc; + if (wait) { + rc = waitForFD(fd, POLLOUT); + if (rc < 0) { + return -errno; + } } - return rc; + jbyte* buf = (*env)->GetByteArrayElements(env, buffer, 0); + rc = write(fd, buf+offset, length); + (*env)->ReleaseByteArrayElements(env, buffer, buf, 0); + if (rc < 0) { + rc = -errno; + } + return rc; } /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jsa...@us...> - 2009-02-05 16:16:43
|
Revision: 125 http://flexotask.svn.sourceforge.net/flexotask/?rev=125&view=rev Author: jsauerbach Date: 2009-02-05 16:16:39 +0000 (Thu, 05 Feb 2009) Log Message: ----------- In NativeIO add the ability to dynamically vary between blocking and non-blocking operations on an individual socket. Add NonBlockingBuffer class to aid in managing partial reads and writes in Flexotask execute methods. Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/util/NativeIO.java trunk/flexotask-functiontest/src/alltests/Testcases.java Added Paths: ----------- trunk/flexotask/src/com/ibm/realtime/flexotask/util/NonBlockingBuffer.java trunk/flexotask-functiontest/src/nativeio/ trunk/flexotask-functiontest/src/nativeio/Main.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/util/NativeIO.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/util/NativeIO.java 2009-02-02 20:49:06 UTC (rev 124) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/util/NativeIO.java 2009-02-05 16:16:39 UTC (rev 125) @@ -33,7 +33,8 @@ * this class also does *something* when the natives are absent, but it is very approximate. Socket writes are * blocking, socket reads use a 1ms timeout, and rs232 I/O is unavailable. * - * Socket reads can also be set to blocking in the simulated case, but not in the flexotask VM run time. + * Individual reads and writes can be optionally changed to "blocking" behavior. An OS poll or ppoll call is used to + * accomplish this. */ public class NativeIO { @@ -49,13 +50,6 @@ /** Constant indicating baud rate of 230400 */ public static final int B230400 = 0010003; - /** Flag indicating that 'connect', 'accept', and 'UDPlisten' functions should produce blocking sockets rather than - * non-blocking. TODO: this use of a static flag is a remnant of an older design in which only the simulated versions - * were affected. Now that the native versions can be either blocking or non-blocking this behavior should be - * specified by call arguments and not by a flag. - */ - public static boolean isBlocking; - /** An arbitrary code used to indicating blocking in the simulated case */ private static final int SIMULATED_BLOCKING_CODE = -2; @@ -67,7 +61,7 @@ /** * Accept a connection on a listening socket (the operation is blocking but the resulting socket is - * non-blocking unless simulating and the isBlocking flag has been set) + * non-blocking) * @param socket the listening socket from which to accept * @return a new non-blocking socket representing a new connection or -errno on error */ @@ -77,15 +71,12 @@ try { Socket realSocket = ((ServerSocket) registry.get(socket)).accept(); realSocket.setTcpNoDelay(true); - if (!isBlocking) { - realSocket.setSoTimeout(1); - } return register(realSocket); } catch (IOException e) { return -1; } } else { - return doAccept(socket, isBlocking); + return doAccept(socket); } } @@ -114,8 +105,7 @@ } /** - * Connect a socket (the operation is blocking but the resulting socket is non-blocking unless simulating and isBlocking has - * been set) + * Connect a socket (the operation is blocking but the resulting socket is non-blocking) * @param host the host to connect * @param port the port to connect to (in host byte order) * @param udp true if a UDP socket is desired, otherwise a TCP socket @@ -132,13 +122,10 @@ } else { Socket socket = new Socket(host, port); socket.setTcpNoDelay(true); - if (!isBlocking) { - socket.setSoTimeout(1); - } return register(socket); } } else { - return doConnect(getHostAddr(host), port, udp, isBlocking); + return doConnect(getHostAddr(host), port, udp); } } @@ -155,6 +142,13 @@ } /** + * Query whether the NativeIO is simulated (if false, the RT native support is being used) + */ + public static boolean isSimulated() { + return simulated; + } + + /** * Create a listening TCP socket (for now, the result is blocking) * @param port the port to listen on * @return a new listening socket or -errno on error @@ -173,7 +167,7 @@ } /** - * Perform non-blocking read on an fd + * Perform a non-blocking read on an fd * @param fd the fd to read * @param buffer the buffer into which to read * @param offset the starting offset at which bytes should be deposited @@ -182,16 +176,33 @@ * or 0 if the connection is closed or a negative number on exceptional condition. The negative number is * the negation of the Unix errno value (e.g. -EWOULDBLOCK indicates data temporarily unavailable) */ - public static int read(int fd, byte[] buffer, int offset, int length) + public static int read(int fd, byte[] buffer, int offset, int length) { + return read(fd, buffer, offset, length, false); + } + + /** + * Perform read on an fd + * @param fd the fd to read + * @param buffer the buffer into which to read + * @param offset the starting offset at which bytes should be deposited + * @param length the number of bytes available at offset + * @param wait if true, wait until there is something to read (blocking behavior), else the usual non-blocking behavior + * @return a positive number of bytes read (which may harmlessly be less than the number requested), + * or 0 if the connection is closed or a negative number on exceptional condition. The negative number is + * the negation of the Unix errno value (e.g. -EWOULDBLOCK indicates data temporarily unavailable) + */ + public static int read(int fd, byte[] buffer, int offset, int length, boolean wait) { if (simulated) { /* Not really nonblocking, except that UDP reads use a 1ms timeout */ Object socket = registry.get(fd); try { if (socket instanceof Socket) { + ((Socket) socket).setSoTimeout(wait ? 0 : 1); InputStream in = ((Socket) socket).getInputStream(); return in.read(buffer, offset, length); } else if (socket instanceof DatagramSocket) { + ((DatagramSocket) socket).setSoTimeout(wait ? 0 : 1); DatagramPacket packet = new DatagramPacket(buffer, offset, length); ((DatagramSocket) socket).receive(packet); return packet.getLength(); @@ -204,7 +215,7 @@ return -1; } } else { - return doRead(fd, buffer, offset, length); + return doRead(fd, buffer, offset, length, wait); } } @@ -234,20 +245,17 @@ if (simulated) { try { DatagramSocket socket = new DatagramSocket(port); - if (!isBlocking) { - socket.setSoTimeout(1); - } return register(socket); } catch (SocketException e) { return -1; } } else { - return doUDPlisten(port, isBlocking); + return doUDPlisten(port); } } /** - * Perform non-blocking write to an fd + * Perform a non-blocking write to an fd * @param fd the fd to write * @param buffer the buffer from which to write * @param offset the starting offset from which bytes should be fetched @@ -256,7 +264,23 @@ * or 0 if the connection is closed or a negative number on exceptional condition. The negative number is * the negation of the Unix errno value (e.g. -EWOULDBLOCK indicates data temporarily unavailable) */ - public static int write(int fd, byte[] buffer, int offset, int length) + public static int write(int fd, byte[] buffer, int offset, int length) { + return write(fd, buffer, offset, length, false); + } + + /** + * Perform a write to an fd + * @param fd the fd to write + * @param buffer the buffer from which to write + * @param offset the starting offset from which bytes should be fetched + * @param length the number of bytes available at offset + * @param wait if true, waits for the fd to be receptive before writing (blocking behavior) else the usual non-blocking + * behavior. This has no effect when simulating. + * @return a positive number of bytes written (which may harmlessly be less than the number requested), + * or 0 if the connection is closed or a negative number on exceptional condition. The negative number is + * the negation of the Unix errno value (e.g. -EWOULDBLOCK indicates data temporarily unavailable) + */ + public static int write(int fd, byte[] buffer, int offset, int length, boolean wait) { if (simulated) { /* Not really nonblocking */ @@ -280,18 +304,18 @@ return -1; } } else { - return doWrite(fd, buffer, offset, length); + return doWrite(fd, buffer, offset, length, wait); } } /** Native for accept */ - private static native int doAccept(int socket, boolean isBlocking); + private static native int doAccept(int socket); /** Native for close */ private static native void doClose(int fd); /** Native for connect */ - private static native int doConnect(int host, int port, boolean udp, boolean isBlocking); + private static native int doConnect(int host, int port, boolean udp); /** Native for getBlockingCode */ private static native int doGetBlockingCode(); @@ -300,16 +324,16 @@ private static native int doListen(int port); /** Native for read */ - private static native int doRead(int fd, byte[] buffer, int offset, int length); + private static native int doRead(int fd, byte[] buffer, int offset, int length, boolean wait); /** Native for rs232 */ private static native int doRs232(String dev, int baudrate); /** Native for UDPlisten */ - private static native int doUDPlisten(int port, boolean isBlocking); + private static native int doUDPlisten(int port); /** Native for write */ - private static native int doWrite(int fd, byte[] buffer, int offset, int length); + private static native int doWrite(int fd, byte[] buffer, int offset, int length, boolean wait); /** * Convenience method for converting a host string to an IPv4 host byte order address @@ -328,7 +352,7 @@ return addr; } - /** + /** * Register a socket, getting back an integer index * @param socket a Socket or ServerSocket object * @return an index that can be used to recover it Added: trunk/flexotask/src/com/ibm/realtime/flexotask/util/NonBlockingBuffer.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/util/NonBlockingBuffer.java (rev 0) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/util/NonBlockingBuffer.java 2009-02-05 16:16:39 UTC (rev 125) @@ -0,0 +1,124 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package com.ibm.realtime.flexotask.util; + + +/** + * A class for use in conjunction with NativeIO for convenient management of non-blocking I/O in a context where a minimal + * amount of data is required for action. + */ +public class NonBlockingBuffer { + private static final int blocking = NativeIO.getBlockingCode(); + + /** The offset of the first unused byte in buffer if it is used for reading and the first unsent byte if it is used + * for writing */ + private int offset; + + /** The data buffer */ + private byte[] buffer; + + /** + * Make a new NonBlockingBuffer for reading + * @param size the size of the buffer + */ + public NonBlockingBuffer(int size) { + buffer = new byte[size]; + } + + /** + * Make a new NonBlockingBuffer for writing + * @param message the message to write + */ + public NonBlockingBuffer(byte[] message) { + buffer = message; + } + + /** + * Reset the buffer to the empty state + */ + public void reset() { + offset = 0; + } + + /** + * Reset the buffer with a new message to write + * @param message the new message to write + */ + public void reset(byte[] message) { + buffer = message; + offset = 0; + } + + /** + * Retrieve the capacity of the buffer + */ + public int size() { + return buffer.length; + } + + /** + * Retrieve the current "occupancy" (bytes read or already written) + */ + public int occupancy() { + return offset; + } + + /** + * Perform a read cycle on a file descriptor and return the occupancy + * @param fd the file descriptor + * @return the occupancy or a negative error indicator (only hard errors, never the blocking code) + */ + public int read(int fd) { + int rc = NativeIO.read(fd, buffer, offset, buffer.length-offset, false); + if (rc < 0 && rc != blocking) { + return rc; + } + offset += (rc == blocking ? 0 : rc); + return offset; + } + + /** + * Perform a write cycle on a file descriptor and return the occupancy + * @param fd the file descriptor + * @return the occupancy or a negative error indicator (only hard errors, never the blocking code) + */ + public int write(int fd) { + int rc = NativeIO.write(fd, buffer, offset, buffer.length-offset, false); + if (rc < 0 && rc != blocking) { + return rc; + } + offset += (rc == blocking ? 0 : rc); + return offset; + } + + /** + * Get the data from the buffer (call when you have enough data after one or more read cycles) + */ + public byte[] getData() { + byte[] ans = new byte[offset]; + System.arraycopy(buffer,0, ans,0, offset); + return ans; + } + + /** + * Convenience method allows a NonBlockingBuffer to be used for reading without using NativeIO + * @param val a byte to add + * @return the occupancy after adding + * @throws ArrayIndexOutOfBoundsException if buffer capacity exceeded + */ + public int addByte(byte val) { + buffer[offset++] = val; + return offset; + } +} Property changes on: trunk/flexotask/src/com/ibm/realtime/flexotask/util/NonBlockingBuffer.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/flexotask-functiontest/src/alltests/Testcases.java =================================================================== --- trunk/flexotask-functiontest/src/alltests/Testcases.java 2009-02-02 20:49:06 UTC (rev 124) +++ trunk/flexotask-functiontest/src/alltests/Testcases.java 2009-02-05 16:16:39 UTC (rev 125) @@ -69,6 +69,12 @@ types.Main.main(new String[0]); } + @Test + public void testNativeIO() throws IOException + { + nativeio.Main.main(new String[0]); + } + /** * Method to test in a non-eclipse environment (e.g. a realtime VM) */ Added: trunk/flexotask-functiontest/src/nativeio/Main.java =================================================================== --- trunk/flexotask-functiontest/src/nativeio/Main.java (rev 0) +++ trunk/flexotask-functiontest/src/nativeio/Main.java 2009-02-05 16:16:39 UTC (rev 125) @@ -0,0 +1,181 @@ +/* + * This file is part of Flexible Task Graphs + * (http://sourceforge.net/projects/flexotasks) + * + * Copyright (c) 2006 - 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + */ +package nativeio; + +import java.io.IOException; +import java.lang.Thread.UncaughtExceptionHandler; + +import com.ibm.realtime.flexotask.scheduling.FlexotaskFileDescriptorState; +import com.ibm.realtime.flexotask.scheduling.FlexotaskWaitSet; +import com.ibm.realtime.flexotask.util.NativeIO; +import com.ibm.realtime.flexotask.util.NonBlockingBuffer; + +/** + * A unit test of the NativeIO, FlexotaskWaitSet and NonBlockingBuffer utilities + */ +public class Main +{ + /* Record any error in secondary thread */ + static Throwable badSender = null; + + /* Main setup */ + public static void main(String[] args) throws IOException { + /* Check environment ... no point in running when only simulating */ + if (NativeIO.isSimulated()) { + System.err.println("NativeIO test not run since native support not present"); + return; + } + + /* Create exception handler for secondary thread */ + UncaughtExceptionHandler handler = new UncaughtExceptionHandler() { + public void uncaughtException(Thread t, Throwable e) { + badSender = e; + } + }; + /* Make secondary thread to use as sender */ + Thread sender = new Thread(new Runnable() { + public void run() { senderRun(); } + }); + sender.setUncaughtExceptionHandler(handler); + sender.setDaemon(true); /* incase receiver aborts */ + /* Run sender, which will wait for receiver to connect */ + sender.start(); + /* Run receiver */ + receiverRun(); + /* Clean up sender */ + try { sender.join(); } catch (InterruptedException e) {} + /* Handle any sender exception */ + if (badSender != null) { + if (badSender instanceof RuntimeException) { + throw (RuntimeException) badSender; + } + if (badSender instanceof Error) { + throw (Error) badSender; + } + throw new IllegalStateException(badSender); + } + } + + /* The receiver loop */ + static void receiverRun() throws IOException { + /* Wait 1 second for sender to fire up */ + try { Thread.sleep(1000); } catch (InterruptedException e) {} + /* Connect to sender */ + int fd = NativeIO.connect("localhost", 9879, false); + if (fd < 0) { + throw new IllegalStateException("Connect rc=" + fd); + } + /* Do a few blocking reads */ + readAndCheck(fd, true, 0); + readAndCheck(fd, true, 1); + readAndCheck(fd, true, 2); + /* Now do some non-blocking ones */ + readAndCheck(fd, false, 3); + readAndCheck(fd, false, 4); + readAndCheck(fd, false, 5); + /* Now do some non-blocking ones with a WaitSet */ + FlexotaskFileDescriptorState state = new FlexotaskFileDescriptorState(fd, FlexotaskFileDescriptorState.READ); + FlexotaskWaitSet waitSet = new FlexotaskWaitSet(new FlexotaskFileDescriptorState[] {state}); + readWithWaitSet(fd, waitSet, 6); + readWithWaitSet(fd, waitSet, 7); + readWithWaitSet(fd, waitSet, 8); + /* Now read remaining contents non-blockingly using NonBlockingBuffer */ + NonBlockingBuffer toRead = new NonBlockingBuffer(102); + int rc = toRead.read(fd); + while (rc >= 0 && rc < 102) { + try { Thread.sleep(200); } catch (InterruptedException e) {} + System.err.print(rc + " "); + rc = toRead.read(fd); + } + if (rc < 0) { + throw new IllegalStateException("NonBlockingBuffer.read() rc=" + fd); + } + } + + /* The sender loop */ + static void senderRun() { + /* Accept a connection from the receiver */ + int listener = NativeIO.listen(9879); + if (listener < 0) { + throw new IllegalStateException("Listen rc=" + listener); + } + int fd = NativeIO.accept(listener); + if (fd < 0) { + throw new IllegalStateException("Accept rc=" + fd); + } + /* Uses NativeIO to send two bytes at a time at 500ms intervals for 30 seconds, using + * '00' through '59' + */ + byte[] buffer = new byte[2]; + for (int i = 0; i < 60; i++) { + buffer[0] = (byte) (i>>8); + buffer[1] = (byte) i; + int rc = NativeIO.write(fd, buffer, 0, 2, true); + if (rc != 2) { + throw new IllegalStateException("Write rc=" + rc); + } + try { Thread.sleep(500); } catch (InterruptedException e) {} + } + } + + /** + * Read a file descriptor and check the value + * @param fd the fd to read + * @param blocking true if a blocking read should be used from the start, false if a non-blocking read should + * be done first before blocking + * @param check the value to check + */ + private static void readAndCheck(int fd, boolean blocking, int check) { + byte[] buffer = new byte[2]; + int rc = NativeIO.read(fd, buffer, 0, 2, blocking); + if (blocking) { + postCheck(check, buffer, rc); + } else if (rc != NativeIO.getBlockingCode()) { + throw new IllegalStateException("Non-blocking read " + check + " should have returned " + NativeIO.getBlockingCode() + + " but returned " + rc); + } else { + readAndCheck(fd, true, check); + } + } + + /** + * Subroutine to check a buffer against a value and a return code + * @param check the value that should be there + * @param buffer the buffer + * @param rc the return code + */ + private static void postCheck(int check, byte[] buffer, int rc) { + if (rc != 2) { + /* Assumes it is impossible for a two-byte write to break up ... is that true? */ + throw new IllegalStateException("Read " + check + " rc=" + rc); + } + int compare = (buffer[0] << 8) | buffer[1]; + if (compare != check) { + throw new IllegalStateException("Read got " + compare + ", should be " + check); + } + } + + /** + * Read a file descriptor non-blockingly using a WaitSet to wait for it and then check the value + * @param fd the fd to read + * @param waitSet the WaitSet to use + * @param check the value to check + */ + private static void readWithWaitSet(int fd, FlexotaskWaitSet waitSet, int check) { + byte[] buffer = new byte[2]; + waitSet.wait(-1, null); + int rc = NativeIO.read(fd, buffer, 0, 2, false); + postCheck(check, buffer, rc); + } +} Property changes on: trunk/flexotask-functiontest/src/nativeio/Main.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jhs...@us...> - 2009-02-02 20:49:18
|
Revision: 124 http://flexotask.svn.sourceforge.net/flexotask/?rev=124&view=rev Author: jhspring Date: 2009-02-02 20:49:06 +0000 (Mon, 02 Feb 2009) Log Message: ----------- Improve model signaling - ID: 2558172 Modified Paths: -------------- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Communicator.java trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Connection.java trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/ModelElement.java trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/NormalTask.java trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Task.java Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Communicator.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Communicator.java 2009-02-02 15:40:27 UTC (rev 123) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Communicator.java 2009-02-02 20:49:06 UTC (rev 124) @@ -48,6 +48,12 @@ /** Property ID for the initialValue property */ private static final int INITIAL_VALUE = 2; + /** Property id for type property */ + private static final String TYPE_PROP = "Communicator.Type"; + + /** Property id for type property */ + private static final String INITIAL_VALUE_PROP = "Communicator.InitialValue"; + /** The type of this special task, as a full Java class name */ private String type = ""; @@ -234,14 +240,19 @@ if (id instanceof ModelProperty) { switch(((ModelProperty) id).id) { case ID: + String oldName = getName(); setName((String) value); - firePropertyChange(LABEL_PROP, null, value); + firePropertyChange(LABEL_PROP, oldName, value); break; case TYPE: + String oldType = getType(); setType(value.toString()); + firePropertyChange(TYPE_PROP, oldType, value); break; case INITIAL_VALUE: + String oldInitialValue = getInitialValue(); setInitialValue((String) value); + firePropertyChange(INITIAL_VALUE_PROP, oldInitialValue, value); break; } } else { Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Connection.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Connection.java 2009-02-02 15:40:27 UTC (rev 123) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Connection.java 2009-02-02 20:49:06 UTC (rev 124) @@ -69,6 +69,21 @@ /** Property id for targetPortBuffering property */ private static final int TARGET_PORT_BUFFERING = 6; + /** Property ID to use when the connection type changed. */ + public static final String TYPE_PROP = "Connection.Type"; + + /** Property ID to use when the connection mode changed. */ + public static final String CONNECTION_MODE_PROP = "Connection.ConnectionMode"; + + /** Property ID to use when the source port buffering changed. */ + public static final String SOURCE_PORT_BUFFERING_PROP = "Connection.SourcePortBuffering"; + + /** Property ID to use when the target port buffering changed. */ + public static final String TARGET_PORT_BUFFERING_PROP = "Connection.TargetPortBuffering"; + + /** Property ID to use when the port declaration property changed. */ + public static final String PORT_DECLARATION_CHANGED_PROP = "Connection.PortDeclarationChanged"; + /** True, if the connection is attached to its endpoints. */ private boolean isConnected; @@ -480,9 +495,13 @@ setTargetPortName((String) null); return; case SOURCE_PORT_BUFFERING: + setSourcePortBuffering(false); + firePropertyChange(SOURCE_PORT_BUFFERING_PROP, null, false); + return; case TARGET_PORT_BUFFERING: - setSourcePortBuffering(false); setTargetPortBuffering(false); + firePropertyChange(TARGET_PORT_BUFFERING_PROP, null, false); + return; case TYPE: setType(""); return; @@ -541,6 +560,7 @@ PortDeclaration portDecl = decls.get(portName); portDecl.isBuffered = isBuffered; task.portDeclarationsChanged(); + firePropertyChange(PORT_DECLARATION_CHANGED_PROP, null, portDecl); } /** @@ -581,6 +601,7 @@ } /* In any case, we notify the task that connectivity to ports has changed */ task.portDeclarationsChanged(); + firePropertyChange(PORT_DECLARATION_CHANGED_PROP, null, latter); } else if (newPort.rename) { /* The new name is to be considered a renaming. This is propagated specially. */ task.portRenamed(former.name, newName, !isTarget); @@ -590,6 +611,7 @@ latter = new PortDeclaration(type, newName); decls.add(latter); task.portDeclarationsChanged(); + firePropertyChange(PORT_DECLARATION_CHANGED_PROP, null, latter); } } @@ -611,26 +633,35 @@ break; case SOURCE_PORT_BUFFERING: { task = (NormalTask) source; + boolean oldValue = sourcePortBuffering; final boolean buffering = ((Integer) value).intValue() == 0; setPortBuffering(false, task, task.getOutputPortDeclarations(), buffering); sourcePortBuffering = ((Integer) value).intValue() == 0; + firePropertyChange(SOURCE_PORT_BUFFERING_PROP, oldValue, sourcePortBuffering); break; } case TARGET_PORT_BUFFERING: { task = (NormalTask) target; + boolean oldValue = targetPortBuffering; final boolean buffering = ((Integer) value).intValue() == 0; setPortBuffering(true, task, task.getInputPortDeclarations(), buffering); targetPortBuffering = ((Integer) value).intValue() == 0; + firePropertyChange(TARGET_PORT_BUFFERING_PROP, oldValue, targetPortBuffering); break; } case TYPE: + String type = getType(); setType(value == null ? null : value.toString()); + firePropertyChange(TYPE_PROP, type, value); break; case MODE: + FlexotaskConnectionMode oldMode = getMode(); setMode(FlexotaskConnectionMode.getConnectionMode((Integer) value)); + firePropertyChange(CONNECTION_MODE_PROP, oldMode, mode); break; case ID: setName(value == null ? null : value.toString()); + firePropertyChange(LABEL_PROP, null, value); break; } } else { @@ -747,6 +778,7 @@ /* Generate a new entry */ PortDeclaration ans = new PortDeclaration(type, stem + portDeclarations.size()); portDeclarations.add(ans); + firePropertyChange(PORT_DECLARATION_CHANGED_PROP, null, ans); return ans; } Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/ModelElement.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/ModelElement.java 2009-02-02 15:40:27 UTC (rev 123) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/ModelElement.java 2009-02-02 20:49:06 UTC (rev 124) @@ -50,6 +50,9 @@ * <p>This class provides property-change support (used to notify edit parts of model changes). */ public abstract class ModelElement implements IPropertySource{ + /** Property ID to use when the label text of this shape is modified */ + public static final String LABEL_PROP = "Shape.LabelText"; + /** Property ID to use when the color of this shape or connection is modified. */ public static final String COLOR_PROP = "Shape.Color"; Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/NormalTask.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/NormalTask.java 2009-02-02 15:40:27 UTC (rev 123) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/NormalTask.java 2009-02-02 20:49:06 UTC (rev 124) @@ -78,6 +78,18 @@ /** The property ID for parameterValue */ private static final int PARAMETER_VALUE = 6; + /** Property ID to use when the implementation class changed. */ + public static final String IMPLEMENTATION_PROP = "NormalTask.ImplementationChanged"; + + /** Property ID to use when the parameter type changed. */ + public static final String PARAMETER_TYPE_PROP = "NormalTask.ParameterTypeChanged"; + + /** Property ID to use when the parameter value changed. */ + public static final String PARAMETER_VALUE_PROP = "NormalTask.ParameterValueChanged"; + + /** Property ID to use when the isolation property changed. */ + public static final String ISOLATION_PROP = "NormalTask.IsolationChanged"; + /** A list of labels for tooltip display representing conflicts found at implementation validation * time and for which no automatic resolution was possible */ private List<Label> conflicts = new ArrayList<Label>(); @@ -392,16 +404,24 @@ firePropertyChange(LABEL_PROP, null, getName()); break; case IMPLEMENTATION: + String implementation = getImplementation(); setImplementation(""); + firePropertyChange(IMPLEMENTATION_PROP, implementation, ""); break; case PARAMETER_TYPE: + String parameterType = getParameterType(); setParameterType(""); + firePropertyChange(PARAMETER_TYPE_PROP, parameterType, ""); break; case PARAMETER_VALUE: + String parameterValue = getParameterValue(); setParameterValue(""); + firePropertyChange(PARAMETER_VALUE_PROP, parameterValue, ""); break; case ISOLATION: + boolean isolation = getCommunicating(); setCommunicating(false); + firePropertyChange(ISOLATION_PROP, isolation, false); break; } } else { @@ -412,6 +432,14 @@ } } } + + /** + * Returns true if this task is a communicating task, otherwise false + * @param true if this task is a communicating task, otherwise false + */ + public boolean getCommunicating() { + return communicating; + } /** * Indicates that this task is a communicating task @@ -490,16 +518,24 @@ firePropertyChange(LABEL_PROP, null, getName()); break; case IMPLEMENTATION: + String implementation = getImplementation(); setImplementationType(((ClassWrapper) value).classType); + firePropertyChange(IMPLEMENTATION_PROP, implementation, getImplementation()); break; case PARAMETER_TYPE: + String parameterType = getParameterType(); setParameterType(value.toString()); + firePropertyChange(PARAMETER_TYPE_PROP, parameterType, getParameterType()); break; case PARAMETER_VALUE: + String parameterValue = getParameterValue(); setParameterValue((String) value); + firePropertyChange(PARAMETER_VALUE_PROP, parameterValue, getParameterValue()); break; case ISOLATION: + boolean isolation = getCommunicating(); setCommunicating(((Integer) value).intValue() > 0); + firePropertyChange(ISOLATION_PROP, isolation, getCommunicating()); break; } } else { Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Task.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Task.java 2009-02-02 15:40:27 UTC (rev 123) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Task.java 2009-02-02 20:49:06 UTC (rev 124) @@ -40,8 +40,6 @@ */ public abstract class Task extends ShapedModelElement { - /** Property ID to use when the label text of this shape is modified */ - public static final String LABEL_PROP = "Shape.LabelText"; /** Property ID to use when the list of outgoing connections is modified. */ public static final String SOURCE_CONNECTIONS_PROP = "Shape.SourceConn"; /** Property ID to use when the list of incoming connections is modified. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jhs...@us...> - 2009-02-02 15:40:39
|
Revision: 123 http://flexotask.svn.sourceforge.net/flexotask/?rev=123&view=rev Author: jhspring Date: 2009-02-02 15:40:27 +0000 (Mon, 02 Feb 2009) Log Message: ----------- fixed bug: oldvalue was reported as new value when firing event concerning removing a connection Modified Paths: -------------- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Task.java Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Task.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Task.java 2009-02-02 15:34:46 UTC (rev 122) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/Task.java 2009-02-02 15:40:27 UTC (rev 123) @@ -143,10 +143,10 @@ } if (conn.getSource() == this) { outgoingConnections.remove(conn); - firePropertyChange(SOURCE_CONNECTIONS_PROP, null, conn); + firePropertyChange(SOURCE_CONNECTIONS_PROP, conn, null); } else if (conn.getTarget() == this) { incomingConnections.remove(conn); - firePropertyChange(TARGET_CONNECTIONS_PROP, null, conn); + firePropertyChange(TARGET_CONNECTIONS_PROP, conn, null); } computeToolTipAndColor(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |