From e42551d53cc9fbff637eaffd64edb7db5572d678 Mon Sep 17 00:00:00 2001 From: klueska Date: Wed, 22 Oct 2008 04:45:12 +0000 Subject: [PATCH] optimization to join wakeup --- .../tosthreads/system/TinyThreadSchedulerP.nc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tos/lib/tosthreads/system/TinyThreadSchedulerP.nc b/tos/lib/tosthreads/system/TinyThreadSchedulerP.nc index ba7f7781..097a7a9a 100644 --- a/tos/lib/tosthreads/system/TinyThreadSchedulerP.nc +++ b/tos/lib/tosthreads/system/TinyThreadSchedulerP.nc @@ -146,19 +146,28 @@ implementation { interrupt(thread); } + void wakeupJoined(thread_t* t) { + int i,j,k; + k = 0; + for(i=0; ijoinedOnMe); i++) { + for(j=0; j<8; j++) { + if(t->joinedOnMe[i] & 0x1) + call ThreadScheduler.wakeupThread(k); + t->joinedOnMe[i] >>= 1; + k++; + } + } + } + /* stop * This routine stops a thread by putting it into the inactive state * and decrementing any necessary variables used to keep track of * threads by the thread scheduler. */ void stop(thread_t* t) { - int i; t->state = TOSTHREAD_STATE_INACTIVE; num_runnable_threads--; - for(i=0; ijoinedOnMe, i)) - call ThreadScheduler.wakeupThread(i); - } + wakeupJoined(t); #ifdef TOSTHREADS_TIMER_OPTIMIZATION post alarmTask(); #else -- 2.39.2