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. |