]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Added thread_join functions and fixed the @spontaneous stuff to not create functions...
authorklueska <klueska>
Mon, 6 Oct 2008 04:40:02 +0000 (04:40 +0000)
committerklueska <klueska>
Mon, 6 Oct 2008 04:40:02 +0000 (04:40 +0000)
37 files changed:
tos/lib/tosthreads/csystem/CAMRadioP.nc
tos/lib/tosthreads/csystem/CAMSerialP.nc
tos/lib/tosthreads/csystem/CBlockStorageP.nc
tos/lib/tosthreads/csystem/CLedsP.nc
tos/lib/tosthreads/csystem/CLinkedListP.nc
tos/lib/tosthreads/csystem/CLogStorageP.nc
tos/lib/tosthreads/csystem/CQueueC.nc
tos/lib/tosthreads/csystem/CThreadP.nc
tos/lib/tosthreads/csystem/CThreadSynchronizationP.nc
tos/lib/tosthreads/csystem/TinyOSEntryPointC.nc
tos/lib/tosthreads/csystem/tosthread.h
tos/lib/tosthreads/interfaces/DynamicThread.nc
tos/lib/tosthreads/interfaces/Thread.nc
tos/lib/tosthreads/interfaces/ThreadInfo.nc
tos/lib/tosthreads/interfaces/ThreadScheduler.nc
tos/lib/tosthreads/lib/net/ctp/CCollectionP.nc
tos/lib/tosthreads/lib/net/lqi/CCollectionP.nc
tos/lib/tosthreads/lib/printf/PrintfP.nc
tos/lib/tosthreads/sensorboards/basicsb/CPhotoP.nc
tos/lib/tosthreads/sensorboards/basicsb/CTempP.nc
tos/lib/tosthreads/sensorboards/tmote_onboard/CHamamatsuS10871TsrP.nc
tos/lib/tosthreads/sensorboards/tmote_onboard/CHamamatsuS1087ParP.nc
tos/lib/tosthreads/sensorboards/tmote_onboard/CSensirionSht11P.nc
tos/lib/tosthreads/sensorboards/universal/CSineSensorP.nc
tos/lib/tosthreads/system/BlockingAMReceiverImplP.nc
tos/lib/tosthreads/system/BlockingResourceC.nc
tos/lib/tosthreads/system/BlockingResourceP.nc
tos/lib/tosthreads/system/DynamicThreadP.nc
tos/lib/tosthreads/system/StaticThreadP.nc
tos/lib/tosthreads/system/ThreadInfoP.nc
tos/lib/tosthreads/system/ThreadMapP.nc
tos/lib/tosthreads/system/ThreadSleepP.nc
tos/lib/tosthreads/system/TinyOSMainP.nc
tos/lib/tosthreads/system/TinyThreadSchedulerC.nc
tos/lib/tosthreads/system/TinyThreadSchedulerP.nc
tos/lib/tosthreads/system/TosMallocC.nc
tos/lib/tosthreads/types/thread.h

index f9d12e12b669b26798c0091edad5db1ce5c276f0..bfe3efe05acf7f4fc011ab530837ce95b0eec845 100644 (file)
@@ -38,82 +38,82 @@ module CAMRadioP {
   }
 }
 implementation {
-  error_t amRadioStart() @C() @spontaneous() { 
+  error_t amRadioStart() @C() AT_SPONTANEOUS { 
     return call BlockingStdControl.start();
   }
-  error_t amRadioStop() @C() @spontaneous() { 
+  error_t amRadioStop() @C() AT_SPONTANEOUS { 
     return call BlockingStdControl.stop();
   }
-  error_t amRadioReceive(message_t* m, uint32_t timeout, am_id_t amId) @C() @spontaneous() {
+  error_t amRadioReceive(message_t* m, uint32_t timeout, am_id_t amId) @C() AT_SPONTANEOUS {
     if(amId == AM_RECEIVE_FROM_ANY)
       return call BlockingReceiveAny.receive(m, timeout);
     else 
       return call BlockingReceive.receive[amId](m, timeout);
   }
-  error_t amRadioSnoop(message_t* m, uint32_t timeout, am_id_t amId) @C() @spontaneous() {
+  error_t amRadioSnoop(message_t* m, uint32_t timeout, am_id_t amId) @C() AT_SPONTANEOUS {
     if(amId == AM_RECEIVE_FROM_ANY)
       return call BlockingSnoopAny.receive(m, timeout);
     else 
       return call BlockingSnoop.receive[amId](m, timeout);
   }
-  error_t amRadioSend(am_addr_t addr, message_t* msg, uint8_t len, am_id_t amId) @C() @spontaneous() {
+  error_t amRadioSend(am_addr_t addr, message_t* msg, uint8_t len, am_id_t amId) @C() AT_SPONTANEOUS {
     return call Send.send[amId](addr, msg, len);
   }
-  am_addr_t amRadioGetLocalAddress() @C() @spontaneous() {
+  am_addr_t amRadioGetLocalAddress() @C() AT_SPONTANEOUS {
     return call AMPacket.address();
   }
-  am_group_t amRadioGetLocalGroup() @C() @spontaneous() {
+  am_group_t amRadioGetLocalGroup() @C() AT_SPONTANEOUS {
     return call AMPacket.localGroup();
   }
-  am_addr_t amRadioGetDestination(message_t* amsg) @C() @spontaneous() {
+  am_addr_t amRadioGetDestination(message_t* amsg) @C() AT_SPONTANEOUS {
     return call AMPacket.destination(amsg);
   }
-  am_addr_t amRadioGetSource(message_t* amsg) @C() @spontaneous() {
+  am_addr_t amRadioGetSource(message_t* amsg) @C() AT_SPONTANEOUS {
     return call AMPacket.source(amsg);
   }
-  void amRadioSetDestination(message_t* amsg, am_addr_t addr) @C() @spontaneous() {
+  void amRadioSetDestination(message_t* amsg, am_addr_t addr) @C() AT_SPONTANEOUS {
     call AMPacket.setDestination(amsg, addr);
   }
-  void amRadioSetSource(message_t* amsg, am_addr_t addr) @C() @spontaneous() {
+  void amRadioSetSource(message_t* amsg, am_addr_t addr) @C() AT_SPONTANEOUS {
     call AMPacket.setSource(amsg, addr);
   }
-  bool amRadioIsForMe(message_t* amsg) @C() @spontaneous() {
+  bool amRadioIsForMe(message_t* amsg) @C() AT_SPONTANEOUS {
     return call AMPacket.isForMe(amsg);
   }
-  am_id_t amRadioGetType(message_t* amsg) @C() @spontaneous() {
+  am_id_t amRadioGetType(message_t* amsg) @C() AT_SPONTANEOUS {
     return call AMPacket.type(amsg);
   }
-  void amRadioSetType(message_t* amsg, am_id_t t) @C() @spontaneous() {
+  void amRadioSetType(message_t* amsg, am_id_t t) @C() AT_SPONTANEOUS {
     call AMPacket.setType(amsg, t);
   }
-  am_group_t amRadioGetGroup(message_t* amsg) @C() @spontaneous() {
+  am_group_t amRadioGetGroup(message_t* amsg) @C() AT_SPONTANEOUS {
     return call AMPacket.group(amsg);
   }
-  void amRadioSetGroup(message_t* amsg, am_group_t grp) @C() @spontaneous() {
+  void amRadioSetGroup(message_t* amsg, am_group_t grp) @C() AT_SPONTANEOUS {
     call AMPacket.setGroup(amsg, grp);
   }
-  void radioClear(message_t* msg) @C() @spontaneous() {
+  void radioClear(message_t* msg) @C() AT_SPONTANEOUS {
     call Packet.clear(msg);
   }
-  uint8_t radioGetPayloadLength(message_t* msg) @C() @spontaneous() {
+  uint8_t radioGetPayloadLength(message_t* msg) @C() AT_SPONTANEOUS {
     return call Packet.payloadLength(msg);
   }
-  void  radioSetPayloadLength(message_t* msg, uint8_t len) @C() @spontaneous() {
+  void  radioSetPayloadLength(message_t* msg, uint8_t len) @C() AT_SPONTANEOUS {
     call Packet.setPayloadLength(msg, len);
   }
-  uint8_t radioMaxPayloadLength() @C() @spontaneous() {
+  uint8_t radioMaxPayloadLength() @C() AT_SPONTANEOUS {
     return call Packet.maxPayloadLength();
   }
-  void* radioGetPayload(message_t* msg, uint8_t len) @C() @spontaneous() {
+  void* radioGetPayload(message_t* msg, uint8_t len) @C() AT_SPONTANEOUS {
     return call Packet.getPayload(msg, len);
   }
-  error_t radioRequestAck( message_t* msg ) @C() @spontaneous() {
+  error_t radioRequestAck( message_t* msg ) @C() AT_SPONTANEOUS {
     return call PacketAcknowledgements.requestAck(msg);
   }
-  error_t radioNoAck( message_t* msg ) @C() @spontaneous() {
+  error_t radioNoAck( message_t* msg ) @C() AT_SPONTANEOUS {
     return call PacketAcknowledgements.noAck(msg);
   }
-  bool radioWasAcked(message_t* msg) @C() @spontaneous() {
+  bool radioWasAcked(message_t* msg) @C() AT_SPONTANEOUS {
     return call PacketAcknowledgements.wasAcked(msg);
   }
 }
index c0a7bba94b1f3951b80c614c1bacfff5c4d6b750..dee9b384cc3e8a7b59bd1723d44c3505b11c2f3c 100644 (file)
@@ -36,76 +36,76 @@ module CAMSerialP {
   }
 }
 implementation {
-  error_t amSerialStart() @C() @spontaneous() { 
+  error_t amSerialStart() @C() AT_SPONTANEOUS { 
     return call BlockingStdControl.start();
   }
-  error_t amSerialStop() @C() @spontaneous() { 
+  error_t amSerialStop() @C() AT_SPONTANEOUS { 
     return call BlockingStdControl.stop();
   }
-  error_t amSerialReceive(message_t* m, uint32_t timeout, am_id_t amId) @C() @spontaneous() {
+  error_t amSerialReceive(message_t* m, uint32_t timeout, am_id_t amId) @C() AT_SPONTANEOUS {
     if(amId == AM_RECEIVE_FROM_ANY)
       return call BlockingReceiveAny.receive(m, timeout);
     else 
       return call BlockingReceive.receive[amId](m, timeout);
   }
-  error_t amSerialSend(am_addr_t addr, message_t* msg, uint8_t len, am_id_t amId) @C() @spontaneous() {
+  error_t amSerialSend(am_addr_t addr, message_t* msg, uint8_t len, am_id_t amId) @C() AT_SPONTANEOUS {
     return call Send.send[amId](addr, msg, len);
   }
-  am_addr_t amSerialLocalAddress() @C() @spontaneous() {
+  am_addr_t amSerialLocalAddress() @C() AT_SPONTANEOUS {
     return call AMPacket.address();
   }
-  am_group_t amSerialGetLocalGroup() @C() @spontaneous() {
+  am_group_t amSerialGetLocalGroup() @C() AT_SPONTANEOUS {
     return call AMPacket.localGroup();
   }
-  am_addr_t amSerialGetDestination(message_t* amsg) @C() @spontaneous() {
+  am_addr_t amSerialGetDestination(message_t* amsg) @C() AT_SPONTANEOUS {
     return call AMPacket.destination(amsg);
   }
-  am_addr_t amSerialGetSource(message_t* amsg) @C() @spontaneous() {
+  am_addr_t amSerialGetSource(message_t* amsg) @C() AT_SPONTANEOUS {
     return call AMPacket.source(amsg);
   }
-  void amSerialSetDestination(message_t* amsg, am_addr_t addr) @C() @spontaneous() {
+  void amSerialSetDestination(message_t* amsg, am_addr_t addr) @C() AT_SPONTANEOUS {
     call AMPacket.setDestination(amsg, addr);
   }
-  void amSerialSetSource(message_t* amsg, am_addr_t addr) @C() @spontaneous() {
+  void amSerialSetSource(message_t* amsg, am_addr_t addr) @C() AT_SPONTANEOUS {
     call AMPacket.setSource(amsg, addr);
   }
-  bool amSerialIsForMe(message_t* amsg) @C() @spontaneous() {
+  bool amSerialIsForMe(message_t* amsg) @C() AT_SPONTANEOUS {
     return call AMPacket.isForMe(amsg);
   }
-  am_id_t amSerialGetType(message_t* amsg) @C() @spontaneous() {
+  am_id_t amSerialGetType(message_t* amsg) @C() AT_SPONTANEOUS {
     return call AMPacket.type(amsg);
   }
-  void amSerialSetType(message_t* amsg, am_id_t t) @C() @spontaneous() {
+  void amSerialSetType(message_t* amsg, am_id_t t) @C() AT_SPONTANEOUS {
     call AMPacket.setType(amsg, t);
   }
-  am_group_t amSerialGetGroup(message_t* amsg) @C() @spontaneous() {
+  am_group_t amSerialGetGroup(message_t* amsg) @C() AT_SPONTANEOUS {
     return call AMPacket.group(amsg);
   }
-  void amSerialSetGroup(message_t* amsg, am_group_t grp) @C() @spontaneous() {
+  void amSerialSetGroup(message_t* amsg, am_group_t grp) @C() AT_SPONTANEOUS {
     call AMPacket.setGroup(amsg, grp);
   }
-  void serialClear(message_t* msg) @C() @spontaneous() {
+  void serialClear(message_t* msg) @C() AT_SPONTANEOUS {
     call Packet.clear(msg);
   }
-  uint8_t serialGetPayloadLength(message_t* msg) @C() @spontaneous() {
+  uint8_t serialGetPayloadLength(message_t* msg) @C() AT_SPONTANEOUS {
     return call Packet.payloadLength(msg);
   }
-  void  serialSetPayloadLength(message_t* msg, uint8_t len) @C() @spontaneous() {
+  void  serialSetPayloadLength(message_t* msg, uint8_t len) @C() AT_SPONTANEOUS {
     call Packet.setPayloadLength(msg, len);
   }
-  uint8_t serialMaxPayloadLength() @C() @spontaneous() {
+  uint8_t serialMaxPayloadLength() @C() AT_SPONTANEOUS {
     return call Packet.maxPayloadLength();
   }
-  void* serialGetPayload(message_t* msg, uint8_t len) @C() @spontaneous() {
+  void* serialGetPayload(message_t* msg, uint8_t len) @C() AT_SPONTANEOUS {
     return call Packet.getPayload(msg, len);
   }
-  error_t serialRequestAck( message_t* msg ) @C() @spontaneous() {
+  error_t serialRequestAck( message_t* msg ) @C() AT_SPONTANEOUS {
     return call PacketAcknowledgements.requestAck(msg);
   }
-  error_t serialNoAck( message_t* msg ) @C() @spontaneous() {
+  error_t serialNoAck( message_t* msg ) @C() AT_SPONTANEOUS {
     return call PacketAcknowledgements.noAck(msg);
   }
-  bool serialWasAcked(message_t* msg) @C() @spontaneous() {
+  bool serialWasAcked(message_t* msg) @C() AT_SPONTANEOUS {
     return call PacketAcknowledgements.wasAcked(msg);
   }
 }
index 82817dcbcce1662101c5b86bc4071a7ea1bc6950..1c3a4bb6db9752e17790710b36f05bbb6d2efb87 100644 (file)
@@ -31,27 +31,27 @@ module CBlockStorageP {
 }
 
 implementation {
-  error_t volumeBlockRead(uint8_t volumeId, storage_addr_t addr, void* buf, storage_len_t* len) @C() @spontaneous()
+  error_t volumeBlockRead(uint8_t volumeId, storage_addr_t addr, void* buf, storage_len_t* len) @C() AT_SPONTANEOUS
   {
     return call BlockingBlock.read[volumeId](addr, buf, len);
   }
   
-  error_t volumeBlockWrite(uint8_t volumeId, storage_addr_t addr, void* buf, storage_len_t* len)  @C() @spontaneous()
+  error_t volumeBlockWrite(uint8_t volumeId, storage_addr_t addr, void* buf, storage_len_t* len)  @C() AT_SPONTANEOUS
   {
     return call BlockingBlock.write[volumeId](addr, buf, len);
   }
   
-  error_t volumeBlockCrc(uint8_t volumeId, storage_addr_t addr, storage_len_t* len, uint16_t crc, uint16_t *finalCrc) @C() @spontaneous()
+  error_t volumeBlockCrc(uint8_t volumeId, storage_addr_t addr, storage_len_t* len, uint16_t crc, uint16_t *finalCrc) @C() AT_SPONTANEOUS
   {
     return call BlockingBlock.computeCrc[volumeId](addr, len, crc, finalCrc);
   }
   
-  error_t volumeBlockErase(uint8_t volumeId) @C() @spontaneous()
+  error_t volumeBlockErase(uint8_t volumeId) @C() AT_SPONTANEOUS
   {
     return call BlockingBlock.erase[volumeId]();
   }
   
-  error_t volumeBlockSync(uint8_t volumeId) @C() @spontaneous()
+  error_t volumeBlockSync(uint8_t volumeId) @C() AT_SPONTANEOUS
   {
     return call BlockingBlock.sync[volumeId]();
   }
index cf1944eb792746529c4c8afbf581772045289701..63fa4773eff764e29927858bfc39ebfec5006365 100644 (file)
@@ -39,40 +39,40 @@ module CLedsP {
   }
 }
 implementation {
-  void led0On() @C() @spontaneous(){
+  void led0On() @C() AT_SPONTANEOUS {
     call Leds.led0On();
   }
-  void led0Off() @C() @spontaneous(){
+  void led0Off() @C() AT_SPONTANEOUS {
     call Leds.led0Off();
   }
-  void led0Toggle() @C() @spontaneous(){
+  void led0Toggle() @C() AT_SPONTANEOUS{
     call Leds.led0Toggle();
   }
 
-  void led1On() @C() @spontaneous(){
+  void led1On() @C() AT_SPONTANEOUS{
     call Leds.led1On();
   }
-  void led1Off() @C() @spontaneous(){
+  void led1Off() @C() AT_SPONTANEOUS{
     call Leds.led1Off();
   }
-  void led1Toggle() @C() @spontaneous(){
+  void led1Toggle() @C() AT_SPONTANEOUS{
     call Leds.led1Toggle();
   }
   
-  void led2On() @C() @spontaneous(){
+  void led2On() @C() AT_SPONTANEOUS{
     call Leds.led2On();
   }
-  void led2Off() @C() @spontaneous(){
+  void led2Off() @C() AT_SPONTANEOUS{
     call Leds.led2Off();
   }
-  void led2Toggle() @C() @spontaneous(){
+  void led2Toggle() @C() AT_SPONTANEOUS{
     call Leds.led2Toggle();
   }
 
-  uint8_t getLeds() @C() @spontaneous(){
+  uint8_t getLeds() @C() AT_SPONTANEOUS{
     return call Leds.get();
   }
-  void setLeds(uint8_t val) @C() @spontaneous(){
+  void setLeds(uint8_t val) @C() AT_SPONTANEOUS{
     call Leds.set(val);
   }
 }
index 33d1cf7a7236d44c709bdcd3cb66ad63eda49d93..ec15e4e756def6e6f521db0153a29f29077dc7c3 100644 (file)
@@ -38,64 +38,64 @@ module CLinkedListP {
   uses interface LinkedList;
 }
 implementation { 
-  void linked_list_init(linked_list_t* l) @C() @spontaneous() {  
+  void linked_list_init(linked_list_t* l) @C() AT_SPONTANEOUS {  
     call LinkedList.init(l);
   }
-  void linked_list_clear(linked_list_t* l) @C() @spontaneous() { 
+  void linked_list_clear(linked_list_t* l) @C() AT_SPONTANEOUS { 
     call LinkedList.clear(l);
   }
-  uint8_t linked_list_size(linked_list_t* l) @C() @spontaneous() { 
+  uint8_t linked_list_size(linked_list_t* l) @C() AT_SPONTANEOUS { 
     return call LinkedList.size(l);
   }
-  error_t linked_list_addFirst(linked_list_t* l, list_element_t* e) @C() @spontaneous() { 
+  error_t linked_list_addFirst(linked_list_t* l, list_element_t* e) @C() AT_SPONTANEOUS { 
     return call LinkedList.addFirst(l, e);
   }
-  list_element_t* linked_list_getFirst(linked_list_t* l) @C() @spontaneous() { 
+  list_element_t* linked_list_getFirst(linked_list_t* l) @C() AT_SPONTANEOUS { 
     return call LinkedList.getFirst(l);
   }
-  list_element_t* linked_list_removeFirst(linked_list_t* l) @C() @spontaneous() { 
+  list_element_t* linked_list_removeFirst(linked_list_t* l) @C() AT_SPONTANEOUS { 
     return call LinkedList.removeFirst(l);
   }
-  error_t linked_list_addLast(linked_list_t* l, list_element_t* e) @C() @spontaneous() { 
+  error_t linked_list_addLast(linked_list_t* l, list_element_t* e) @C() AT_SPONTANEOUS { 
     return call LinkedList.addLast(l, e);
   }
-  list_element_t* linked_list_getLast(linked_list_t* l) @C() @spontaneous() { 
+  list_element_t* linked_list_getLast(linked_list_t* l) @C() AT_SPONTANEOUS { 
     return call LinkedList.getLast(l);
   }
-  list_element_t* linked_list_removeLast(linked_list_t* l) @C() @spontaneous() { 
+  list_element_t* linked_list_removeLast(linked_list_t* l) @C() AT_SPONTANEOUS { 
     return call LinkedList.removeLast(l);
   }
-  error_t linked_list_addAt(linked_list_t* l, list_element_t* e, uint8_t i) @C() @spontaneous() { 
+  error_t linked_list_addAt(linked_list_t* l, list_element_t* e, uint8_t i) @C() AT_SPONTANEOUS { 
     return call LinkedList.addAt(l, e, i);
   }
-  list_element_t* linked_list_getAt(linked_list_t* l, uint8_t i) @C() @spontaneous() { 
+  list_element_t* linked_list_getAt(linked_list_t* l, uint8_t i) @C() AT_SPONTANEOUS { 
     return call LinkedList.getAt(l, i);
   }
-  list_element_t* linked_list_removeAt(linked_list_t* l, uint8_t i) @C() @spontaneous() { 
+  list_element_t* linked_list_removeAt(linked_list_t* l, uint8_t i) @C() AT_SPONTANEOUS { 
     return call LinkedList.removeAt(l, i);
   }  
-  error_t linked_list_addAfter(linked_list_t* l, list_element_t* first, list_element_t* second) @C() @spontaneous() { 
+  error_t linked_list_addAfter(linked_list_t* l, list_element_t* first, list_element_t* second) @C() AT_SPONTANEOUS { 
     return call LinkedList.addAfter(l, first, second);
   }
-  error_t linked_list_addBefore(linked_list_t* l, list_element_t* first, list_element_t* e) @C() @spontaneous() { 
+  error_t linked_list_addBefore(linked_list_t* l, list_element_t* first, list_element_t* e) @C() AT_SPONTANEOUS { 
     return call LinkedList.addBefore(l, first, e);
   }
-  list_element_t* linked_list_getAfter(linked_list_t* l, list_element_t* e) @C() @spontaneous() { 
+  list_element_t* linked_list_getAfter(linked_list_t* l, list_element_t* e) @C() AT_SPONTANEOUS { 
     return call LinkedList.getAfter(l, e);
   }  
-  list_element_t* linked_list_getBefore(linked_list_t* l, list_element_t* e) @C() @spontaneous() { 
+  list_element_t* linked_list_getBefore(linked_list_t* l, list_element_t* e) @C() AT_SPONTANEOUS { 
     return call LinkedList.getBefore(l, e);
   }
-  list_element_t* linked_list_remove(linked_list_t* l, list_element_t* e) @C() @spontaneous() { 
+  list_element_t* linked_list_remove(linked_list_t* l, list_element_t* e) @C() AT_SPONTANEOUS { 
     return call LinkedList.remove(l, e);
   }  
-  list_element_t* linked_list_removeBefore(linked_list_t* l, list_element_t* e) @C() @spontaneous() { 
+  list_element_t* linked_list_removeBefore(linked_list_t* l, list_element_t* e) @C() AT_SPONTANEOUS { 
     return call LinkedList.removeBefore(l, e);
   }  
-  list_element_t* linked_list_removeAfter(linked_list_t* l, list_element_t* e) @C() @spontaneous() { 
+  list_element_t* linked_list_removeAfter(linked_list_t* l, list_element_t* e) @C() AT_SPONTANEOUS { 
     return call LinkedList.removeAfter(l, e);
   }  
-  uint8_t linked_list_indexOf(linked_list_t* l, list_element_t* e) @C() @spontaneous() { 
+  uint8_t linked_list_indexOf(linked_list_t* l, list_element_t* e) @C() AT_SPONTANEOUS { 
     return call LinkedList.indexOf(l, e);
   }
 }
index 04f0db59898ec0ebc1307afc280b3d7747442bb8..92638a7d5bc72663438950fbe2d872ccda6d70c5 100644 (file)
@@ -39,28 +39,28 @@ module CLogStorageP {
   }
 }
 implementation {
-  error_t volumeLogRead(uint8_t volumeId, void *buf, storage_len_t *len) @C() @spontaneous() {
+  error_t volumeLogRead(uint8_t volumeId, void *buf, storage_len_t *len) @C() AT_SPONTANEOUS {
     return call BlockingLog.read[volumeId](buf, len);
   }
-  storage_cookie_t volumeLogCurrentReadOffset(uint8_t volumeId) @C() @spontaneous() {
+  storage_cookie_t volumeLogCurrentReadOffset(uint8_t volumeId) @C() AT_SPONTANEOUS {
     return call BlockingLog.currentReadOffset[volumeId]();
   }
-  error_t volumeLogSeek(uint8_t volumeId, storage_cookie_t offset) @C() @spontaneous() {
+  error_t volumeLogSeek(uint8_t volumeId, storage_cookie_t offset) @C() AT_SPONTANEOUS {
     return call BlockingLog.seek[volumeId](offset);
   }
-  storage_len_t volumeLogGetSize(uint8_t volumeId) @C() @spontaneous() {
+  storage_len_t volumeLogGetSize(uint8_t volumeId) @C() AT_SPONTANEOUS {
     return call BlockingLog.getSize[volumeId]();
   }  
-  error_t volumeLogAppend(uint8_t volumeId, void* buf, storage_len_t *len, bool *recordsLost) @C() @spontaneous() {
+  error_t volumeLogAppend(uint8_t volumeId, void* buf, storage_len_t *len, bool *recordsLost) @C() AT_SPONTANEOUS {
     return call BlockingLog.append[volumeId](buf, len, recordsLost);
   }
-  storage_cookie_t volumeLogCurrentWriteOffset(uint8_t volumeId) @C() @spontaneous() {
+  storage_cookie_t volumeLogCurrentWriteOffset(uint8_t volumeId) @C() AT_SPONTANEOUS {
     return call BlockingLog.currentWriteOffset[volumeId]();
   }
-  error_t volumeLogErase(uint8_t volumeId) @C() @spontaneous() {
+  error_t volumeLogErase(uint8_t volumeId) @C() AT_SPONTANEOUS {
     return call BlockingLog.erase[volumeId]();
   }
-  error_t volumeLogSync(uint8_t volumeId) @C() @spontaneous() {
+  error_t volumeLogSync(uint8_t volumeId) @C() AT_SPONTANEOUS {
     return call BlockingLog.sync[volumeId]();
   }
 }
index 267c1c6dee6d62b052359496b0d74e710dcbc491..6d958cbdc1d78423831fa77d00f5c18d0363fa58 100644 (file)
 
 module CQueueC {}
 implementation { 
-  void queue_init(queue_t* q) @C() @spontaneous() {  
+  void queue_init(queue_t* q) @C() AT_SPONTANEOUS {  
     linked_list_init( &(q->l) );
   }
-  void queue_clear(queue_t* q) @C() @spontaneous() { 
+  void queue_clear(queue_t* q) @C() AT_SPONTANEOUS { 
     linked_list_clear( &(q->l) );
   }
-  error_t queue_enqueue(queue_t* q, queue_element_t* e) @C() @spontaneous() { 
+  error_t queue_enqueue(queue_t* q, queue_element_t* e) @C() AT_SPONTANEOUS { 
     return linked_list_addLast(&(q->l), (list_element_t*)e);
   }
-  queue_element_t* queue_dequeue(queue_t* q) @C() @spontaneous() { 
+  queue_element_t* queue_dequeue(queue_t* q) @C() AT_SPONTANEOUS { 
     return (queue_element_t*)linked_list_removeFirst( &(q->l) );
   }
-  queue_element_t* queue_remove(queue_t* q, queue_element_t* e) @C() @spontaneous() { 
+  queue_element_t* queue_remove(queue_t* q, queue_element_t* e) @C() AT_SPONTANEOUS { 
     return (queue_element_t*)linked_list_remove(&(q->l), (list_element_t*)e);
   }
-  uint8_t queue_size(queue_t* q) @C() @spontaneous() { 
+  uint8_t queue_size(queue_t* q) @C() AT_SPONTANEOUS { 
     return linked_list_size( &(q->l) );
   }
-  bool queue_is_empty(queue_t* q) @C() @spontaneous() { 
+  bool queue_is_empty(queue_t* q) @C() AT_SPONTANEOUS { 
     return (linked_list_size( &(q->l) ) == 0);
   }
 }
index 52f160131a4dd1a4df8bcb477e8b19cfc21912a2..18026f17f6faf6d6e461b2f2e402262253824082 100644 (file)
@@ -42,19 +42,22 @@ module CThreadP {
 }
 implementation {
 
-  error_t tosthread_create(tosthread_t* t, void (*start_routine)(void*), void* arg, uint16_t stack_size) @C() @spontaneous() {
+  error_t tosthread_create(tosthread_t* t, void (*start_routine)(void*), void* arg, uint16_t stack_size) @C() AT_SPONTANEOUS {
     return call DynamicThread.create(t, start_routine, arg, stack_size);
   }
-  error_t tosthread_destroy(tosthread_t* t) @C() @spontaneous() {
+  error_t tosthread_destroy(tosthread_t* t) @C() AT_SPONTANEOUS {
     return call DynamicThread.destroy(t);
   }
-  error_t tosthread_pause(tosthread_t* t) @C() @spontaneous() {
+  error_t tosthread_pause(tosthread_t* t) @C() AT_SPONTANEOUS {
     return call DynamicThread.pause(t);
   }
-  error_t tosthread_resume(tosthread_t* t) @C() @spontaneous() {
+  error_t tosthread_resume(tosthread_t* t) @C() AT_SPONTANEOUS {
     return call DynamicThread.resume(t);
   }
-  error_t tosthread_sleep(uint32_t milli) @C() @spontaneous() {
+  error_t tosthread_sleep(uint32_t milli) @C() AT_SPONTANEOUS {
     return call DynamicThread.sleep(milli);
   }
+  error_t tosthread_join(tosthread_t* t) @C() AT_SPONTANEOUS {
+    return call DynamicThread.join(t);
+  }
 }
index 952c48d1027831cbc86e4568c9f113abcce696ab..a82b9e0e3dab431001ce031a7719116de43a6b9f 100644 (file)
@@ -44,69 +44,69 @@ module CThreadSynchronizationP {
 }
 implementation {
   /******************** Mutex ***************************/
-  void mutex_init(mutex_t* m) @C() @spontaneous() {
+  void mutex_init(mutex_t* m) @C() AT_SPONTANEOUS {
     call Mutex.init(m);
   }
-  error_t mutex_lock(mutex_t* m) @C() @spontaneous() {
+  error_t mutex_lock(mutex_t* m) @C() AT_SPONTANEOUS {
     return call Mutex.lock(m);
   }
-  error_t mutex_unlock(mutex_t* m) @C() @spontaneous() {
+  error_t mutex_unlock(mutex_t* m) @C() AT_SPONTANEOUS {
     return call Mutex.unlock(m);
   }
   
   /******************** Semaphore ***************************/
-  void semaphore_reset(semaphore_t* s, uint8_t v) @C() @spontaneous() {
+  void semaphore_reset(semaphore_t* s, uint8_t v) @C() AT_SPONTANEOUS {
     call Semaphore.reset(s, v);
   }
-  error_t semaphore_acquire(semaphore_t* s) @C() @spontaneous() {
+  error_t semaphore_acquire(semaphore_t* s) @C() AT_SPONTANEOUS {
     return call Semaphore.acquire(s);
   }
-  error_t semaphore_release(semaphore_t* s) @C() @spontaneous() {
+  error_t semaphore_release(semaphore_t* s) @C() AT_SPONTANEOUS {
     return call Semaphore.release(s);
   }
   
   /******************** Barrier ***************************/
-  void barrier_reset(barrier_t* b, uint8_t count) @C() @spontaneous() {
+  void barrier_reset(barrier_t* b, uint8_t count) @C() AT_SPONTANEOUS {
     call Barrier.reset(b, count);
   }
-  void barrier_block(barrier_t* b) @C() @spontaneous() {
+  void barrier_block(barrier_t* b) @C() AT_SPONTANEOUS {
     call Barrier.block(b);
   }
-  bool barrier_isBlocking(barrier_t* b) @C() @spontaneous() {
+  bool barrier_isBlocking(barrier_t* b) @C() AT_SPONTANEOUS {
     return call Barrier.isBlocking(b);
   }
-  void condvar_init(condvar_t* c) @C() @spontaneous() {
+  void condvar_init(condvar_t* c) @C() AT_SPONTANEOUS {
     call ConditionVariable.init(c);
   }
   
   /******************** Condition Variable ***************************/
-  void condvar_wait(condvar_t* c, mutex_t* m) @C() @spontaneous() {
+  void condvar_wait(condvar_t* c, mutex_t* m) @C() AT_SPONTANEOUS {
     call ConditionVariable.wait(c, m);
   }
-  void condvar_signalNext(condvar_t* c) @C() @spontaneous() {
+  void condvar_signalNext(condvar_t* c) @C() AT_SPONTANEOUS {
     call ConditionVariable.signalNext(c);
   }
-  void condvar_signalAll(condvar_t* c) @C() @spontaneous() {
+  void condvar_signalAll(condvar_t* c) @C() AT_SPONTANEOUS {
     call ConditionVariable.signalAll(c);
   }
-  bool condvar_isBlocking(condvar_t* c) @C() @spontaneous() {
+  bool condvar_isBlocking(condvar_t* c) @C() AT_SPONTANEOUS {
     return call ConditionVariable.isBlocking(c);
   }
   
   /******************** Reference Counter ***************************/
-  void refcounter_init(refcounter_t* r) @C() @spontaneous() {
+  void refcounter_init(refcounter_t* r) @C() AT_SPONTANEOUS {
     call ReferenceCounter.init(r);
   }
-  void refcounter_increment(refcounter_t* r) @C() @spontaneous() {
+  void refcounter_increment(refcounter_t* r) @C() AT_SPONTANEOUS {
     call ReferenceCounter.increment(r);
   }
-  void refcounter_decrement(refcounter_t* r) @C() @spontaneous() {
+  void refcounter_decrement(refcounter_t* r) @C() AT_SPONTANEOUS {
     call ReferenceCounter.decrement(r);
   }
-  void refcounter_waitOnValue(refcounter_t* r, uint8_t count) @C() @spontaneous() {
+  void refcounter_waitOnValue(refcounter_t* r, uint8_t count) @C() AT_SPONTANEOUS {
     call ReferenceCounter.waitOnValue(r, count);
   }
-  uint8_t refcounter_count(refcounter_t* r) @C() @spontaneous() {
+  uint8_t refcounter_count(refcounter_t* r) @C() AT_SPONTANEOUS {
     return call ReferenceCounter.count(r);
   }
 }
index d55f5a613a9aa3279d94dfbdd45d81cf28b704e9..25befbd745e14ca07c2ff91537905c1c0147f6a5 100644 (file)
  
 #include "tosthread.h"
 
+#ifdef DYNTHREADS 
+  #define AT_SPONTANEOUS       @spontaneous()
+#else
+  #define AT_SPONTANEOUS
+#endif
+
 configuration TinyOSEntryPointC {
 }
 implementation {
index b032ad54599529f75a99d85c13117e5ca098cdce..3c1551c904391f560f8cefcb9fa94fca121940d3 100644 (file)
@@ -120,4 +120,17 @@ extern error_t tosthread_resume(tosthread_t* t);
  */
 extern error_t tosthread_sleep(uint32_t milli);
 
+/**
+ *  tosthread_join(tosthread_t* t)
+ *
+ *  This function bocks until the thread passed as a parameter has completed
+ *  
+ *  @param id                  The handle to the thread to block on
+ *  @return                            An error code indicating whether the thread could be waited on or not
+ *                                                     SUCCESS         -       The thread has been waited on and is now completed
+ *                                                     EALREADY        -       The thread we are trying to wait on has already completed
+ *                                                     FAIL            -       The thread could not waited on
+ */
+extern error_t tosthread_join(tosthread_t* id);
+
 #endif //TOSTHREAD_H_INCLUDED
index aea023c905a347d44c58c60a73ab56528a7bd5f7..d3d26264632bb95606fb1f2503cd3632f8bab8c8 100644 (file)
@@ -102,4 +102,17 @@ interface DynamicThread {
    *                                                   FAIL            -       The thread could not be put to sleep
    */
   command error_t sleep(uint32_t milli);
+  
+  /**
+   *  join(tosthread_t* t)
+   *
+   *  This function bocks until the thread passed as a parameter has completed
+   *  
+   *  @param id                        The handle to the thread to block on
+   *  @return                          An error code indicating whether the thread could be waited on or not
+   *                                                   SUCCESS         -       The thread has been waited on and is now completed
+   *                                                   EALREADY        -       The thread we are trying to wait on has already completed
+   *                                                   FAIL            -       The thread could not waited on
+   */
+  command error_t join(tosthread_t* id);
 }  
index 15b93f6c1257740a52f8107adb8ee64507ff9b7b..0fc2f4602fbd70a187d791c6abc1874ee6059bfc 100644 (file)
@@ -40,4 +40,5 @@ interface Thread {
   command error_t resume();
   command error_t sleep(uint32_t milli);
   event void run(void* arg);
+  command error_t join();
 }  
index d98379fc05a5ea7586d92afc7e7f5f0f995dea11..df244c1c4a00e558c90245cb81a5b3167b7358b9 100644 (file)
@@ -36,5 +36,6 @@
 #include "thread.h"
 
 interface ThreadInfo {
+  async command error_t reset();
   async command thread_t* get();
 }  
index 089460807addda6779380e342e5103894cef971e..c682d28a3a0b5c68e7cdef9a0559c57e2a1d2283 100644 (file)
@@ -48,4 +48,5 @@ interface ThreadScheduler {
   async command error_t interruptCurrentThread();
 
   async command error_t wakeupThread(thread_id_t id);
+  async command error_t joinThread(thread_id_t id);
 }
index 8b5fbdf2ac3c47cddcbfd112d42f25fcd0747db3..5b7ee8a7da4b7e26004f6c4ab52e1c347e89de16 100644 (file)
@@ -54,69 +54,69 @@ implementation {
     return call CCollectionId.fetch(id);
   }
 
-  error_t collectionSetCollectionId(uint8_t clientid, collection_id_t collectionid) @C() @spontaneous() {
+  error_t collectionSetCollectionId(uint8_t clientid, collection_id_t collectionid) @C() AT_SPONTANEOUS {
     return call CCollectionId.set(clientid, collectionid);
   }
   
-  error_t collectionRoutingStart() @C() @spontaneous() {
+  error_t collectionRoutingStart() @C() AT_SPONTANEOUS {
     return call RoutingControl.start();
   }
-  error_t collectionRoutingStop() @C() @spontaneous() {
+  error_t collectionRoutingStop() @C() AT_SPONTANEOUS {
     return call RoutingControl.stop();
   }
 
-  error_t collectionReceive(message_t* m, uint32_t timeout, collection_id_t id) @C() @spontaneous() {
+  error_t collectionReceive(message_t* m, uint32_t timeout, collection_id_t id) @C() AT_SPONTANEOUS {
     return call BlockingReceive.receive[id](m, timeout);
   }
-  error_t collectionSnoop(message_t* m, uint32_t timeout, collection_id_t id) @C() @spontaneous() {
+  error_t collectionSnoop(message_t* m, uint32_t timeout, collection_id_t id) @C() AT_SPONTANEOUS {
     return call BlockingSnoop.receive[id](m, timeout);
   }
-  error_t collectionSend(message_t* msg, uint8_t len, uint8_t id) @C() @spontaneous() {
+  error_t collectionSend(message_t* msg, uint8_t len, uint8_t id) @C() AT_SPONTANEOUS {
     return call BlockingSend.send[id](msg, len);
   }
  
-  void collectionClear(message_t* msg) @C() @spontaneous() {
+  void collectionClear(message_t* msg) @C() AT_SPONTANEOUS {
     call Packet.clear(msg);
   }
-  uint8_t collectionGetPayloadLength(message_t* msg) @C() @spontaneous() {
+  uint8_t collectionGetPayloadLength(message_t* msg) @C() AT_SPONTANEOUS {
     return call Packet.payloadLength(msg);
   }
-  void collectionSetPayloadLength(message_t* msg, uint8_t len) @C() @spontaneous() {
+  void collectionSetPayloadLength(message_t* msg, uint8_t len) @C() AT_SPONTANEOUS {
     call Packet.setPayloadLength(msg, len);
   }
-  uint8_t collectionMaxPayloadLength() @C() @spontaneous() {
+  uint8_t collectionMaxPayloadLength() @C() AT_SPONTANEOUS {
     return call Packet.maxPayloadLength();
   }
-  void* collectionGetPayload(message_t* msg, uint8_t len) @C() @spontaneous() {
+  void* collectionGetPayload(message_t* msg, uint8_t len) @C() AT_SPONTANEOUS {
     return call Packet.getPayload(msg, len);
   }
 
-  am_addr_t collectionGetOrigin(message_t* msg) @C() @spontaneous() {
+  am_addr_t collectionGetOrigin(message_t* msg) @C() AT_SPONTANEOUS {
     return call CollectionPacket.getOrigin(msg);
   }
-  void collectionSetOrigin(message_t* msg, am_addr_t addr) @C() @spontaneous() {
+  void collectionSetOrigin(message_t* msg, am_addr_t addr) @C() AT_SPONTANEOUS {
     call CollectionPacket.setOrigin(msg, addr);
   }
-  collection_id_t collectionGetType(message_t* msg) @C() @spontaneous() {
+  collection_id_t collectionGetType(message_t* msg) @C() AT_SPONTANEOUS {
     return call CollectionPacket.getType(msg);
   }
-  void collectionSetType(message_t* msg, collection_id_t id) @C() @spontaneous() {
+  void collectionSetType(message_t* msg, collection_id_t id) @C() AT_SPONTANEOUS {
     call CollectionPacket.setType(msg, id);
   }
-  uint8_t collectionGetSequenceNumber(message_t* msg) @C() @spontaneous() {
+  uint8_t collectionGetSequenceNumber(message_t* msg) @C() AT_SPONTANEOUS {
     return call CollectionPacket.getSequenceNumber(msg);
   }
-  void collectionSetSequenceNumber(message_t* msg, uint8_t seqno) @C() @spontaneous() {
+  void collectionSetSequenceNumber(message_t* msg, uint8_t seqno) @C() AT_SPONTANEOUS {
     call CollectionPacket.setSequenceNumber(msg, seqno);
   }
 
-  error_t collectionSetRoot() @C() @spontaneous() {
+  error_t collectionSetRoot() @C() AT_SPONTANEOUS {
     return call RootControl.setRoot();
   }
-  error_t collectionUnsetRoot() @C() @spontaneous() {
+  error_t collectionUnsetRoot() @C() AT_SPONTANEOUS {
     return call RootControl.unsetRoot();
   }
-  bool collectionIsRoot() @C() @spontaneous() {
+  bool collectionIsRoot() @C() AT_SPONTANEOUS {
     return call RootControl.isRoot();
   }
 }
index 5782f23f162f1c6d30b8d4f8e82cf840144f5c7a..8d2b3d5874bcddc631ac12cdad24a871a2618af1 100644 (file)
@@ -54,70 +54,70 @@ implementation {
     return call CCollectionId.fetch(id);
   }
 
-  error_t collectionSetCollectionId(uint8_t clientid, collection_id_t collectionid) @C() @spontaneous() {
+  error_t collectionSetCollectionId(uint8_t clientid, collection_id_t collectionid) @C() AT_SPONTANEOUS {
     return call CCollectionId.set(clientid, collectionid);
   }
   
-  error_t collectionRoutingStart() @C() @spontaneous() {
+  error_t collectionRoutingStart() @C() AT_SPONTANEOUS {
     return call RoutingControl.start();
   }
-  error_t collectionRoutingStop() @C() @spontaneous() {
+  error_t collectionRoutingStop() @C() AT_SPONTANEOUS {
     return call RoutingControl.stop();
   }
 
-  error_t collectionReceive(message_t* m, uint32_t timeout, collection_id_t id) @C() @spontaneous() {
+  error_t collectionReceive(message_t* m, uint32_t timeout, collection_id_t id) @C() AT_SPONTANEOUS {
     return call BlockingReceive.receive[id](m, timeout);
   }
-  error_t collectionSnoop(message_t* m, uint32_t timeout, collection_id_t id) @C() @spontaneous() {
+  error_t collectionSnoop(message_t* m, uint32_t timeout, collection_id_t id) @C() AT_SPONTANEOUS {
     return call BlockingSnoop.receive[id](m, timeout);
   }
-  error_t collectionSend(message_t* msg, uint8_t len, uint8_t id) @C() @spontaneous() {
+  error_t collectionSend(message_t* msg, uint8_t len, uint8_t id) @C() AT_SPONTANEOUS {
     call CollectionPacket.setType(msg, call CCollectionId.fetch(id));
     return call BlockingSend.send[id](msg, len);
   }
  
-  void collectionClear(message_t* msg) @C() @spontaneous() {
+  void collectionClear(message_t* msg) @C() AT_SPONTANEOUS {
     call Packet.clear(msg);
   }
-  uint8_t collectionGetPayloadLength(message_t* msg) @C() @spontaneous() {
+  uint8_t collectionGetPayloadLength(message_t* msg) @C() AT_SPONTANEOUS {
     return call Packet.payloadLength(msg);
   }
-  void collectionSetPayloadLength(message_t* msg, uint8_t len) @C() @spontaneous() {
+  void collectionSetPayloadLength(message_t* msg, uint8_t len) @C() AT_SPONTANEOUS {
     call Packet.setPayloadLength(msg, len);
   }
-  uint8_t collectionMaxPayloadLength() @C() @spontaneous() {
+  uint8_t collectionMaxPayloadLength() @C() AT_SPONTANEOUS {
     return call Packet.maxPayloadLength();
   }
-  void* collectionGetPayload(message_t* msg, uint8_t len) @C() @spontaneous() {
+  void* collectionGetPayload(message_t* msg, uint8_t len) @C() AT_SPONTANEOUS {
     return call Packet.getPayload(msg, len);
   }
 
-  am_addr_t collectionGetOrigin(message_t* msg) @C() @spontaneous() {
+  am_addr_t collectionGetOrigin(message_t* msg) @C() AT_SPONTANEOUS {
     return call CollectionPacket.getOrigin(msg);
   }
-  void collectionSetOrigin(message_t* msg, am_addr_t addr) @C() @spontaneous() {
+  void collectionSetOrigin(message_t* msg, am_addr_t addr) @C() AT_SPONTANEOUS {
     call CollectionPacket.setOrigin(msg, addr);
   }
-  collection_id_t collectionGetType(message_t* msg) @C() @spontaneous() {
+  collection_id_t collectionGetType(message_t* msg) @C() AT_SPONTANEOUS {
     return call CollectionPacket.getType(msg);
   }
-  void collectionSetType(message_t* msg, collection_id_t id) @C() @spontaneous() {
+  void collectionSetType(message_t* msg, collection_id_t id) @C() AT_SPONTANEOUS {
     call CollectionPacket.setType(msg, id);
   }
-  uint8_t collectionGetSequenceNumber(message_t* msg) @C() @spontaneous() {
+  uint8_t collectionGetSequenceNumber(message_t* msg) @C() AT_SPONTANEOUS {
     return call CollectionPacket.getSequenceNumber(msg);
   }
-  void collectionSetSequenceNumber(message_t* msg, uint8_t seqno) @C() @spontaneous() {
+  void collectionSetSequenceNumber(message_t* msg, uint8_t seqno) @C() AT_SPONTANEOUS {
     call CollectionPacket.setSequenceNumber(msg, seqno);
   }
 
-  error_t collectionSetRoot() @C() @spontaneous() {
+  error_t collectionSetRoot() @C() AT_SPONTANEOUS {
     return call RootControl.setRoot();
   }
-  error_t collectionUnsetRoot() @C() @spontaneous() {
+  error_t collectionUnsetRoot() @C() AT_SPONTANEOUS {
     return call RootControl.unsetRoot();
   }
-  bool collectionIsRoot() @C() @spontaneous() {
+  bool collectionIsRoot() @C() AT_SPONTANEOUS {
     return call RootControl.isRoot();
   }
 }
index 5f164bfac2130f3e963841ae4626b05ca43724f3..47dcccfe1adff5ed3fa0be007d40dd197af4cd87 100644 (file)
@@ -108,7 +108,7 @@ implementation {
     }
   }
 
-  int printfflush() @C() @spontaneous() {
+  int printfflush() @C() AT_SPONTANEOUS {
     call Barrier.block(&flushstart_barrier);
     call Barrier.reset(&flushstart_barrier, 2);
     call Barrier.block(&flushdone_barrier);
index 51aeeff320bcd97b9153f63708e6dffa827456c9..f1baf8e7998cc552f74d48000bfff138e7322b8c 100644 (file)
@@ -40,10 +40,10 @@ module CPhotoP {
   }
 }
 implementation {
-  error_t photo_read(uint16_t* val) @C() @spontaneous() {
+  error_t photo_read(uint16_t* val) @C() AT_SPONTANEOUS {
     return call BlockingRead.read(val);
   }
-  error_t photo_readStream(uint32_t* usPeriod, uint16_t* buf, uint16_t count) @C() @spontaneous() {
+  error_t photo_readStream(uint32_t* usPeriod, uint16_t* buf, uint16_t count) @C() AT_SPONTANEOUS {
     return call BlockingReadStream.read(usPeriod, buf, count);
   }
 }
index 1bcc8d9eb26944bededb2362eeeecb90ceceb655..a9efc9c2163a3f51dfa808ea4693696ae971c966 100644 (file)
@@ -40,10 +40,10 @@ module CTempP {
   }
 }
 implementation {
-  error_t temp_read(uint16_t* val) @C() @spontaneous() {
+  error_t temp_read(uint16_t* val) @C() AT_SPONTANEOUS {
     return call BlockingRead.read(val);
   }
-  error_t temp_readStream(uint32_t* usPeriod, uint16_t* buf, uint16_t count) @C() @spontaneous() {
+  error_t temp_readStream(uint32_t* usPeriod, uint16_t* buf, uint16_t count) @C() AT_SPONTANEOUS {
     return call BlockingReadStream.read(usPeriod, buf, count);
   }
 }
index 8346ee8d82137d368370b6d58c539b5db84ca01f..84d43ac46a966928865664abb82b3207b0ff83b0 100644 (file)
@@ -41,13 +41,13 @@ module CHamamatsuS10871TsrP {
   }
 }
 implementation {
-  error_t hamamatsuS10871_tsr_read(uint16_t* val) @C() @spontaneous() {
+  error_t hamamatsuS10871_tsr_read(uint16_t* val) @C() AT_SPONTANEOUS {
     return call Read.read(val);
   }
-  error_t hamamatsuS10871_tsr_readStream(uint32_t* usPeriod, uint16_t* buf, uint16_t count) @C() @spontaneous() {
+  error_t hamamatsuS10871_tsr_readStream(uint32_t* usPeriod, uint16_t* buf, uint16_t count) @C() AT_SPONTANEOUS {
     return call ReadStream.read(usPeriod, buf, count);                                           
   }                                            
-  uint8_t hamamatsuS10871_tsr_getNumBits() @C() @spontaneous() {
+  uint8_t hamamatsuS10871_tsr_getNumBits() @C() AT_SPONTANEOUS {
     return call DeviceMetadata.getSignificantBits();
   }
 }
index 683b606cf3dc67753d7503772a9a525e722e6a15..6afd3f77a2fc130b50ba00c5ffcb598166a73171 100644 (file)
@@ -42,13 +42,13 @@ module CHamamatsuS1087ParP {
 }
 implementation {
 
-  error_t hamamatsuS1087_par_read(uint16_t* val) @C() @spontaneous() {
+  error_t hamamatsuS1087_par_read(uint16_t* val) @C() AT_SPONTANEOUS {
     return call Read.read(val);
   }
-  error_t hamamatsuS1087_par_readStream(uint32_t* usPeriod, uint16_t* buf, uint16_t count) @C() @spontaneous() {
+  error_t hamamatsuS1087_par_readStream(uint32_t* usPeriod, uint16_t* buf, uint16_t count) @C() AT_SPONTANEOUS {
     return call ReadStream.read(usPeriod, buf, count);                                           
   }                                           
-  uint8_t hamamatsuS1087_par_getNumBits() @C() @spontaneous() {
+  uint8_t hamamatsuS1087_par_getNumBits() @C() AT_SPONTANEOUS {
     return call DeviceMetadata.getSignificantBits();
   }
 }
index 38ba3e80f6bf2cb29f710c12e3d8ac10e66dbf42..1e478ab81d5740cc1f892ff006d6702e97a47958 100644 (file)
@@ -42,16 +42,16 @@ module CSensirionSht11P {
   }
 }
 implementation {
-  error_t sensirionSht11_humidity_read(uint16_t* val) @C() @spontaneous() {
+  error_t sensirionSht11_humidity_read(uint16_t* val) @C() AT_SPONTANEOUS {
     return call Humidity.read(val);
   }
-  uint8_t sensirionSht11_humidity_getNumBits() @C() @spontaneous() {
+  uint8_t sensirionSht11_humidity_getNumBits() @C() AT_SPONTANEOUS {
     return call HumidityMetadata.getSignificantBits();
   }
-  error_t sensirionSht11_temperature_read(uint16_t* val) @C() @spontaneous() {
+  error_t sensirionSht11_temperature_read(uint16_t* val) @C() AT_SPONTANEOUS {
     return call Temperature.read(val);
   }
-  uint8_t sensirionSht11_temperature_getNumBits() @C() @spontaneous() {
+  uint8_t sensirionSht11_temperature_getNumBits() @C() AT_SPONTANEOUS {
     return call TemperatureMetadata.getSignificantBits();
   }
 }
index 63f197d557882a07133b2497f2e8fdde4fac6390..770362a97fba96b27efd1cc627fca722e29c07f7 100644 (file)
@@ -39,7 +39,7 @@ module CSineSensorP {
   }
 }
 implementation {
-  error_t sinesensor_read(uint16_t* val) @C() @spontaneous() {
+  error_t sinesensor_read(uint16_t* val) @C() AT_SPONTANEOUS {
     return call BlockingRead.read(val);
   }
 }
index c2c7fa4ae8a8b9db15bea63bff7456224f7e7eca..e9b6b4ed3743edbc5609dea78aeb9712f79a00e4 100644 (file)
@@ -52,8 +52,8 @@ generic module BlockingAMReceiverImplP() {
 implementation {
   
   typedef struct params {
-    message_t* msg;
     uint32_t*  timeout;
+    message_t* msg;
     error_t    error;
   } params_t;
 
index fc14b25393e56697debf506cc25ddffe2792468d..e7a4532eb3e92840b1ed4373358ca54482ca2153 100644 (file)
@@ -47,8 +47,8 @@ implementation {
   BlockingResource = BlockingResourceP;
   Resource = BlockingResourceP;
   
-  components ThreadTimersC;
-  BlockingResourceP.Timer -> ThreadTimersC;
+  components ThreadSleepC;
+  BlockingResourceP.ThreadSleep -> ThreadSleepC;
   
   components SystemCallC;
   components TinyThreadSchedulerC;
index b3e69a7298503168f4a2674857b6a044b64d7958..2821185e6c727b6add787ecadf556b5a0b8b0be3 100644 (file)
@@ -41,12 +41,11 @@ generic module BlockingResourceP() {
     interface SystemCall;
     interface ThreadScheduler;
     interface Resource;
-    interface Timer<TMilli>[uint8_t id];
+    interface ThreadSleep;
   }
 }
 implementation {
   typedef struct params {
-    uint32_t* milli;
     error_t   error;
   } params_t;
   
@@ -108,11 +107,6 @@ implementation {
   }
   
   /************************* Timed Release *****************************/
-  void timerTask(syscall_t* s) {
-    params_t* p = s->params;
-    call Timer.startOneShot[s->thread->id](*(p->milli));
-  }    
-  
   command error_t BlockingResource.timedRelease(uint32_t milli) {
     syscall_t s;
     params_t p;
@@ -122,15 +116,12 @@ implementation {
       resource_call = &s;
     }
     
-    if(milli != 0) {
-      p.milli = &milli;
-      call SystemCall.start(timerTask, &s, INVALID_ID, &p);
-    }
-    else {
-      call SystemCall.start(releaseTask, &s, INVALID_ID, &p); 
-      if(p.error == SUCCESS)
-        call SystemCall.start(requestTask, &s, INVALID_ID, &p); 
-    }
+    if(milli != 0)
+      call ThreadSleep.sleep(milli);
+
+    call SystemCall.start(releaseTask, &s, INVALID_ID, &p); 
+    if(p.error == SUCCESS)
+      call SystemCall.start(requestTask, &s, INVALID_ID, &p); 
     
     atomic {
       resource_call = NULL;
@@ -138,16 +129,6 @@ implementation {
     }  
   }
   
-  event void Timer.fired[uint8_t id]() {
-    thread_t* t = call ThreadScheduler.threadInfo(id);
-    syscall_t* s = t->syscall;
-    params_t* p = t->syscall->params;
-    call SystemCall.start(releaseTask, s, INVALID_ID, p); 
-    if(p->error == SUCCESS)
-      call SystemCall.start(requestTask, s, INVALID_ID, p);   
-    else call SystemCall.finish(s); 
-  }
-  
   /************************* isOwner pass through *****************************/
   command error_t BlockingResource.isOwner() {
     return call Resource.isOwner();
index cb4cd804a62745c524e9563aae2ddaa724df2ba1..de03f20dda0c6c04ebb1c1c96405fa3d549cd4be 100644 (file)
@@ -137,11 +137,18 @@ happy:
   command error_t DynamicThread.sleep(uint32_t milli) {
     return call ThreadSleep.sleep(milli);
   }
+  command error_t DynamicThread.join(tosthread_t* t) {
+    return call ThreadScheduler.joinThread(*t);
+  }
   
   async command thread_t* ThreadInfo.get[uint8_t id]() {
     atomic return thread_info[id - TOSTHREAD_NUM_STATIC_THREADS];
   }
   
+  async command error_t ThreadInfo.reset[uint8_t id]() {
+    return FAIL;
+  }
+  
   async event void ThreadCleanup.cleanup[uint8_t id]() {
     signal ThreadNotification.aboutToDestroy[id]();
     atomic {
index ace29d103769c7027c0a6d757d4f422c56cebe39..8b10acbc2fc5926d455b0e45e85f5a5bf952d55b 100644 (file)
@@ -54,7 +54,7 @@ implementation {
     thread_info->start_arg_ptr = arg; 
     thread_info->mutex_count = 0;
     thread_info->next_thread = NULL;
-    return call ThreadScheduler.initThread(id);
+    return ecombine(call ThreadInfo.reset[id](), call ThreadScheduler.initThread(id));
   }
   
   command error_t Thread.start[uint8_t id](void* arg) {
@@ -87,6 +87,10 @@ implementation {
     return call ThreadSleep.sleep(milli);
   }
   
+  command error_t Thread.join[uint8_t id]() {
+    return call ThreadScheduler.joinThread(id);
+  }
+  
   event void ThreadFunction.signalThreadRun[uint8_t id](void *arg) {
     signal Thread.run[id](arg);
   }
@@ -97,6 +101,7 @@ implementation {
   
   default event void Thread.run[uint8_t id](void* arg) {}
   default async command thread_t* ThreadInfo.get[uint8_t id]() {return NULL;}
+  default async command error_t ThreadInfo.reset[uint8_t id]() {return FAIL;}
   default async event void ThreadNotification.justCreated[uint8_t id]() {}
   default async event void ThreadNotification.aboutToDestroy[uint8_t id]() {}
 
index b971299a73332db7e94787892c94f5c39836b38b..c9cd980eab70638c69309d76275ae674f9323d40 100644 (file)
@@ -51,7 +51,7 @@ implementation {
     signal ThreadFunction.signalThreadRun(arg);
   }
   
-  command error_t Init.init() {
+  error_t init() {
     thread_info.next_thread = NULL;
     thread_info.id = thread_id;
     thread_info.init_block = NULL;
@@ -64,6 +64,14 @@ implementation {
     return SUCCESS;
   }
   
+  command error_t Init.init() {
+    return init();
+  }
+  
+  async command error_t ThreadInfo.reset() {
+    return init();
+  }
+  
   async command thread_t* ThreadInfo.get() {
     return &thread_info;
   }
index 9b4861a9dfc52f2cdfcc9472e93209fa132c9445..805260516e696aa4b5231d83e33442c3a2eaf1da 100644 (file)
@@ -50,12 +50,21 @@ implementation {
   async command thread_t* ThreadInfo.get[uint8_t id]() {
     return call StaticThreadInfo.get[id]();
   }
+  async command error_t ThreadInfo.reset[uint8_t id]() {
+    return call StaticThreadInfo.reset[id]();
+  }
   default async command thread_t* StaticThreadInfo.get[uint8_t id]() {
     return call DynamicThreadInfo.get[id]();
   }
+  default async command error_t StaticThreadInfo.reset[uint8_t id]() {
+    return call DynamicThreadInfo.reset[id]();
+  }
   default async command thread_t* DynamicThreadInfo.get[uint8_t id]() {
     return call StaticThreadInfo.get[id]();
   }
+  default async command error_t DynamicThreadInfo.reset[uint8_t id]() {
+    return call StaticThreadInfo.reset[id]();
+  }
   async event void ThreadCleanup.cleanup[uint8_t id]() {
     signal StaticThreadCleanup.cleanup[id]();
   }
index 65554cf0298b61291e3572adfd156570afcce5fe..d78212d99aa729b7ee10410a1a3dbb60a288ef05 100644 (file)
@@ -62,8 +62,20 @@ implementation {
     return SUCCESS;
   }
   
+  //Need to add a cancel command so that components like
+  //BlockingAMReceiverImplP can use the ThreadSleep interface
+  //directly instead of reusing the underlying ThreadTimerC 
+  //component.  The current implementation does things this way
+  //and causes us to be defensive in here since the same 
+  //TimerMilli.fired() event is sent to that component as well.
+  //Basically its just broken....  cancel() would get rid of this.
+  
+  //Also need some sort of a sleepWithSyscall command
+  //Need to think about this one a little more
+  
   event void TimerMilli.fired[uint8_t id]() {
     thread_t* t = call ThreadScheduler.threadInfo(id);
-    call SystemCall.finish(t->syscall);
+    if(t->syscall->syscall_ptr == sleepTask)
+           call SystemCall.finish(t->syscall);
   }
 }
index 2df6d5df357c351c65ae1888f61641f73e5fb65a..75d06aa1683d5bf2d9669c5dac81959d8f75573b 100644 (file)
@@ -93,6 +93,10 @@ implementation {
     call TaskScheduler.taskLoop();
     
   }
+  
+  async command error_t ThreadInfo.reset() {
+    return FAIL;
+  }
 
   async command thread_t* ThreadInfo.get() {
     return &thread_info;
index cf5c283daed1a9e29ffb9099ced62b9360b774fc..0d4d60362e21fff87b805af5340610b808e1c943 100644 (file)
@@ -57,6 +57,9 @@ implementation {
   ThreadScheduler = Sched;
   Sched.McuSleep -> Sleep;
   
+  components BitArrayUtilsC;
+  Sched.BitArrayUtils -> BitArrayUtilsC;
+  
   components ThreadQueueC;
   Sched.ThreadQueue -> ThreadQueueC;
   
index 1ae67708558488bad103d2c6760a5a5d2dd75864..e93af1916ba4dbc45ae2f1e745f04d7b2a22a693 100644 (file)
@@ -43,6 +43,7 @@ module TinyThreadSchedulerP {
     interface Boot as ThreadSchedulerBoot;
     interface ThreadInfo[uint8_t id];
     interface ThreadQueue;
+    interface BitArrayUtils;
     interface McuSleep;
     interface Leds;
     interface Timer<TMilli> as PreemptionAlarm;
@@ -138,8 +139,13 @@ implementation {
    * threads by the thread scheduler.
    */
    void stop(thread_t* t) {
+     int i;
      t->state = TOSTHREAD_STATE_INACTIVE;
      num_started_threads--;
+     for(i=0; i<TOSTHREAD_MAX_NUM_THREADS; i++) {
+       if(call BitArrayUtils.getBit(t->joinedOnMe, i))
+         call ThreadScheduler.wakeupThread(i);
+        }
      if(num_started_threads == 1)
        call PreemptionAlarm.stop();
      signal ThreadCleanup.cleanup[t->id]();
@@ -178,6 +184,7 @@ implementation {
     thread_t* t = (call ThreadInfo.get[id]());
     t->state = TOSTHREAD_STATE_INACTIVE;
     t->init_block = current_thread->init_block;
+    call BitArrayUtils.clrArray(t->joinedOnMe, sizeof(t->joinedOnMe));
     PREPARE_THREAD(t, threadWrapper);
     return SUCCESS;
   }
@@ -232,6 +239,20 @@ implementation {
     }
   }
   
+  async command error_t ThreadScheduler.joinThread(thread_id_t id) { 
+    thread_t* t = call ThreadInfo.get[id]();
+    atomic {
+      if(current_thread == tos_thread)
+        return FAIL;
+      if (t->state != TOSTHREAD_STATE_INACTIVE) {
+        call BitArrayUtils.setBit(t->joinedOnMe, current_thread->id);
+        call ThreadScheduler.suspendCurrentThread();
+        return SUCCESS;
+      }
+    }
+    return EALREADY;
+  }
+  
   async command error_t ThreadScheduler.wakeupThread(uint8_t id) {
     thread_t* t = call ThreadInfo.get[id]();
     if((t->state) == TOSTHREAD_STATE_SUSPENDED) {
index 7f811e2b212834bde22dc2f01a9372f03d72b9ba..8de2ba39feee80323f7482b146256357ac543fc4 100644 (file)
@@ -52,7 +52,7 @@ implementation {
 
   size_t malloc_heap[MALLOC_HEAP_SIZE];
 
-  void *tos_malloc (size_t size) @C() @spontaneous()
+  void *tos_malloc (size_t size) @C() AT_SPONTANEOUS
   {
     static char once = 0;
     size_t * heap_bottom = &(malloc_heap[MALLOC_HEAP_SIZE]);
@@ -103,7 +103,7 @@ implementation {
     return NULL;
   }
 
-  void tos_free (void *p) @C() @spontaneous()
+  void tos_free (void *p) @C() AT_SPONTANEOUS
   {
     size_t *t = (size_t*)p - 1;
     MARK_FREE (t);
index c86d9f744c902ac49988ea913a26cff81c92d7cf..87df6121e3ca55813ed9d38eb75581b7f1fbd5a2 100644 (file)
@@ -94,7 +94,6 @@ struct syscall {
 };
 
 //This is a thread data structure
-//This structure is 43 bytes long...
 struct thread {
   //***** next_thread must be at first position in struct for casting purposes *******
   volatile struct thread* next_thread;  //Pointer to next thread for use in queues when blocked
@@ -103,6 +102,7 @@ struct thread {
   stack_ptr_t stack_ptr;                //Pointer to this threads stack
   volatile uint8_t state;               //Current state the thread is in
   volatile uint8_t mutex_count;         //A reference count of the number of mutexes held by this thread
+  uint8_t joinedOnMe[(TOSTHREAD_MAX_NUM_THREADS - 1) / 8 + 1]; //Bitmask of threads waiting for me to finish
   void (*start_ptr)(void*);             //Pointer to the start function of this thread
   void* start_arg_ptr;                  //Pointer to the argument passed as a parameter to the start function of this thread
   syscall_t* syscall;                   //Pointer to an instance of a system call