]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Fixed bug that allowed isOwner() to return false ownership between pending requests...
authorklueska <klueska>
Fri, 24 Aug 2007 16:10:09 +0000 (16:10 +0000)
committerklueska <klueska>
Fri, 24 Aug 2007 16:10:09 +0000 (16:10 +0000)
tos/system/ArbiterP.nc
tos/system/SimpleArbiterP.nc

index 9650a7073a22cd6e0316fac6dd27063c10163601..872b71f6fa8a99ad8ce3a4cb712f0e9988a391c4 100644 (file)
@@ -66,6 +66,7 @@ implementation {
 
   enum {RES_CONTROLLED, RES_GRANTING, RES_IMM_GRANTING, RES_BUSY};
   enum {default_owner_id = default_owner_id};
+  enum {NO_RES = 0xFF};
 
   uint8_t state = RES_CONTROLLED;
   norace uint8_t resId = default_owner_id;
@@ -144,6 +145,10 @@ implementation {
     Check if the Resource is currently in use
   */    
   async command bool ArbiterInfo.inUse() {
+    atomic {
+      if (state == RES_CONTROLLED)
+        return FALSE;
+    }
     return TRUE;
   }
 
@@ -153,7 +158,11 @@ implementation {
     will be 0xFF
   */      
   async command uint8_t ArbiterInfo.userId() {
-    atomic return resId;
+    atomic {
+      if(state != RES_BUSY)
+        return NO_RES;
+      return resId;
+    }
   }
 
   /**
@@ -161,7 +170,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;
     }
   }
index c5e82f290b1be35491db3e63e11f6e671e0d4a14..91d883a0bce74daf3b097ebe5d4437be276496be 100644 (file)
@@ -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;
     }
   }