X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fsystem%2FArbiterP.nc;h=b07f975dc4e5b2b2e762a90c020aff7772ec43cf;hb=e9bfab607e051bae6afb47b44892ce37541d1b44;hp=c25f69f4a04f35855416a816581e12809c29d8d6;hpb=82750daecbe6775396deac36c32510a09cd4eb4c;p=tinyos-2.x.git diff --git a/tos/system/ArbiterP.nc b/tos/system/ArbiterP.nc index c25f69f4..b07f975d 100644 --- a/tos/system/ArbiterP.nc +++ b/tos/system/ArbiterP.nc @@ -49,7 +49,7 @@ * @author Philip Levis */ -generic module ArbiterP(uint8_t default_owner_id) { +generic module ArbiterP(uint8_t default_owner_id) @safe() { provides { interface Resource[uint8_t id]; interface ResourceRequested[uint8_t id]; @@ -110,15 +110,18 @@ implementation { if(state == RES_BUSY && resId == id) { if(call Queue.isEmpty() == FALSE) { reqResId = call Queue.dequeue(); + resId = NO_RES; state = RES_GRANTING; post grantedTask(); + call ResourceConfigure.unconfigure[id](); } else { resId = default_owner_id; state = RES_CONTROLLED; + call ResourceConfigure.unconfigure[id](); signal ResourceDefaultOwner.granted(); } - call ResourceConfigure.unconfigure[id](); + return SUCCESS; } } return FAIL; @@ -176,7 +179,9 @@ implementation { } async command uint8_t ResourceDefaultOwner.isOwner() { - atomic return (state == RES_CONTROLLED); + atomic return (state == RES_CONTROLLED + || (resId == default_owner_id + && (state == RES_GRANTING || state == RES_IMM_GRANTING))); } task void grantedTask() {