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