From: klueska Date: Fri, 24 Aug 2007 16:10:09 +0000 (+0000) Subject: Fixed bug that allowed isOwner() to return false ownership between pending requests... X-Git-Tag: release_tinyos_2_1_0_0~780 X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=commitdiff_plain;h=12ab8ebcade3a0ecd693c71e63e04cc857111776;p=tinyos-2.x.git Fixed bug that allowed isOwner() to return false ownership between pending requests being granted. --- diff --git a/tos/system/ArbiterP.nc b/tos/system/ArbiterP.nc index 9650a707..872b71f6 100644 --- a/tos/system/ArbiterP.nc +++ b/tos/system/ArbiterP.nc @@ -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; } } diff --git a/tos/system/SimpleArbiterP.nc b/tos/system/SimpleArbiterP.nc index c5e82f29..91d883a0 100644 --- a/tos/system/SimpleArbiterP.nc +++ b/tos/system/SimpleArbiterP.nc @@ -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; } }