Hi

I am using the latest TInyos 2.x from Subersion, on a Shimmer (MSP430) mote.

I am experiencing unexpected behaviour using the Thread.pause() and 
Thread,resume() functions when using TosThreads.
My understanding is that when Thread.pause() is called from within a thread it 
should sleep, until another thread or event calls Thread.resume().  However, I 
am finding that while Thread.pause() returns SUCCESS, the thread continues 
executing.

When using condition a variable the thread waiting on the condition variable 
sleeps until the condition variable is signalled.

I notice in tinyos-2.x/tos/lib/tosthreads/system/StaticThreadP.nc, which 
provides the Thread interface, Thread.pause() calls 
ThreadScheduler.stopThread(), whereas I would have expected it to call 
ThreadScheduler.suspendCurrentThread() as is the case with the condition 
variable implementation.  Using the patch below makes Thread.pause() and 
Thread.resume() function as expected.

Have I misinterpreted the way pause and resume should function? Does this fix 
make sense?

Thanks
David

----------------------------------------------------------------------------------------------------------
Index: StaticThreadP.nc
===================================================================
--- StaticThreadP.nc    (revision 5307)
+++ StaticThreadP.nc    (working copy)
@@ -73,11 +73,11 @@
   }

   command error_t Thread.pause[uint8_t id]() {
-    return call ThreadScheduler.stopThread(id);
+    return call ThreadScheduler.suspendCurrentThread();
   }

   command error_t Thread.resume[uint8_t id]() {
-    return call ThreadScheduler.startThread(id);
+    return call ThreadScheduler.wakeupThread(id);
   }

   command error_t Thread.stop[uint8_t id]() {

---------------------------------------- End Diff 
------------------------------------------------------

The information in this e-mail may be confidential and subject to legal 
professional privilege and/or copyright. National ICT Australia Limited accepts 
no liability for any damage caused by this email or its attachments.

_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to