From: <jsa...@us...> - 2008-10-28 13:49:33
|
Revision: 44 http://flexotask.svn.sourceforge.net/flexotask/?rev=44&view=rev Author: jsauerbach Date: 2008-10-28 13:49:20 +0000 (Tue, 28 Oct 2008) Log Message: ----------- Make the number of threads and runnables visible to the master runnable before requesting the coordination lock count so that it can more easily answer the question. Submitted by Jia Zou. Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSingleThreadRunner.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSingleThreadRunner.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSingleThreadRunner.java 2008-10-27 16:15:09 UTC (rev 43) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/FlexotaskSingleThreadRunner.java 2008-10-28 13:49:20 UTC (rev 44) @@ -350,16 +350,16 @@ if (nRunnables > 1) { System.arraycopy(otherRunnables,0, runnables,1, nRunnables-1); } + /* Ensure that the otherThreads and otherRunnables arrays are pre-initialized so that they will be cloned */ + if (nRunnables > 1) { + toClone.otherRunnables = new FlexotaskSchedulerRunnable[nRunnables-1]; + toClone.otherThreads = new Thread[nRunnables-1]; + } /* Create the requested number of locks (at least one) to be pinned by the factory */ Object[] theLocks = new Object[toClone.getThreadCoordinationLockCount() + 1]; for (int i = 0; i < theLocks.length; i++) { theLocks[i] = new Object(); } - /* Ensure that the otherThreads and otherRunnables arrays are pre-initialized so that they will be cloned */ - if (nRunnables > 1) { - toClone.otherRunnables = new FlexotaskSchedulerRunnable[nRunnables-1]; - toClone.otherThreads = new Thread[nRunnables-1]; - } /* Run the thread factory to obtain threads and clone the runnables */ Thread[] allThreads = threadFactory.createThreads(runnables, theLocks); /* Stow the slave threads and cloned runnables in their rightful place in the cloned master runnable */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |