]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/system/SharedArbiterP.nc
Race condition clearing bit vectors that are already clear in Init.init.
[tinyos-2.x.git] / tos / system / SharedArbiterP.nc
index f13e03c2cc3cc503568d9e12864fca1e64d16e8e..40afb970ed91b670578ba4091ac385d323eb3115 100644 (file)
@@ -38,7 +38,6 @@
 
 generic module SharedArbiterP() {
   provides {
-    interface Init;
     interface Resource[uint8_t id];
     interface ResourceDefaultOwner;
     interface ArbiterInfo;
@@ -117,13 +116,6 @@ implementation {
     }
   }
 
-  command error_t Init.init()
-  {
-    call GrantedVector.clearAll();
-    call RequestingVector.clearAll();
-    return SUCCESS;
-  }
-
   async command error_t Resource.request[uint8_t id]()
   {
     /* The Resource docs do not say what happens when a user calls
@@ -173,14 +165,11 @@ implementation {
 
   async command error_t ResourceDefaultOwner.release()
   {
-    atomic {
-      if (m_requesting > 0) {
-       call State.forceState(S_GRANTED);
-       post grantedTask();
-       return SUCCESS;
-      } else
-       return FAIL;
-    }
+    if (call State.requestState(S_GRANTED) == SUCCESS) {
+      post grantedTask();
+      return SUCCESS;
+    } else
+      return FAIL;
   }
 
   async command bool ArbiterInfo.inUse()