]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/system/SimpleArbiterP.nc
Upstream commits to tos/chips/cc2420, Aug 7 2008 thru Jul 16 2009, except one.
[tinyos-2.x.git] / tos / system / SimpleArbiterP.nc
index c5e82f290b1be35491db3e63e11f6e671e0d4a14..ac4c839e40c6660866a555f1ad0e346a39229b67 100644 (file)
@@ -46,7 +46,7 @@
  * @author Philip Levis
  */
  
-generic module SimpleArbiterP() {
+generic module SimpleArbiterP() @safe() {
   provides {
     interface Resource[uint8_t id];
     interface ResourceRequested[uint8_t id];
@@ -134,7 +134,11 @@ implementation {
     will be 0xFF
   */      
   async command uint8_t ArbiterInfo.userId() {
-    atomic return resId;
+    atomic {
+      if(state != RES_BUSY)
+        return NO_RES;
+      return resId;
+    }
   }
 
   /**
@@ -142,7 +146,7 @@ implementation {
    */      
   async command uint8_t Resource.isOwner[uint8_t id]() {
     atomic {
-      if(resId == id) return TRUE;
+      if(resId == id && state == RES_BUSY) return TRUE;
       else return FALSE;
     }
   }