]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
optimization to join wakeup
authorklueska <klueska>
Wed, 22 Oct 2008 04:45:12 +0000 (04:45 +0000)
committerklueska <klueska>
Wed, 22 Oct 2008 04:45:12 +0000 (04:45 +0000)
tos/lib/tosthreads/system/TinyThreadSchedulerP.nc

index ba7f77812e1c35715ac0cd521897560ffd635f89..097a7a9a9c550dd9676f0cae85b4c2fc6a85ec73 100644 (file)
@@ -146,19 +146,28 @@ implementation {
     interrupt(thread);
   }
   
+  void wakeupJoined(thread_t* t) {
+    int i,j,k;
+    k = 0;
+    for(i=0; i<sizeof(t->joinedOnMe); 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; i<TOSTHREAD_MAX_NUM_THREADS; i++) {
-      if(call BitArrayUtils.getBit(t->joinedOnMe, i))
-        call ThreadScheduler.wakeupThread(i);
-    }
+    wakeupJoined(t);
     #ifdef TOSTHREADS_TIMER_OPTIMIZATION
          post alarmTask();    
        #else