X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fsystem%2FSimpleArbiterP.nc;h=30f185f2e99926602161b29f6652717f326437a4;hb=738579ccc0bce339be74aad761c7286258433e93;hp=c5e82f290b1be35491db3e63e11f6e671e0d4a14;hpb=d9c5479d38caf5e9b147f5f99c29af63fe6a33ae;p=tinyos-2.x.git diff --git a/tos/system/SimpleArbiterP.nc b/tos/system/SimpleArbiterP.nc index c5e82f29..30f185f2 100644 --- a/tos/system/SimpleArbiterP.nc +++ b/tos/system/SimpleArbiterP.nc @@ -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]; @@ -99,6 +99,7 @@ implementation { atomic { if(state == RES_BUSY && resId == id) { if(call Queue.isEmpty() == FALSE) { + resId = NO_RES; reqResId = call Queue.dequeue(); state = RES_GRANTING; post grantedTask(); @@ -134,7 +135,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 +147,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; } }