X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fsystem%2FSimpleArbiterP.nc;h=30f185f2e99926602161b29f6652717f326437a4;hb=e9bfab607e051bae6afb47b44892ce37541d1b44;hp=a3cfcae8106a4a6196dcc8a4e35f6a68acd4238a;hpb=ec0de8e1ac425b0f6855d46f737c2726cd82df88;p=tinyos-2.x.git diff --git a/tos/system/SimpleArbiterP.nc b/tos/system/SimpleArbiterP.nc index a3cfcae8..30f185f2 100644 --- a/tos/system/SimpleArbiterP.nc +++ b/tos/system/SimpleArbiterP.nc @@ -41,14 +41,12 @@ * there are no pending requests, then the resource becomes idle and any * user can put in a request and immediately receive access to the * Resource. - * - * @param resourceName -- The name of the Resource being shared * * @author Kevin Klues (klues@tkn.tu-berlin.de) * @author Philip Levis */ -generic module SimpleArbiterP() { +generic module SimpleArbiterP() @safe() { provides { interface Resource[uint8_t id]; interface ResourceRequested[uint8_t id]; @@ -101,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(); @@ -136,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; + } } /** @@ -144,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; } }