* @author Philip Levis
*/
-generic module SimpleArbiterP() {
+generic module SimpleArbiterP() @safe() {
provides {
interface Resource[uint8_t id];
interface ResourceRequested[uint8_t id];
atomic {
if(state == RES_BUSY && resId == id) {
if(call Queue.isEmpty() == FALSE) {
+ resId = NO_RES;
reqResId = call Queue.dequeue();
state = RES_GRANTING;
post grantedTask();
will be 0xFF
*/
async command uint8_t ArbiterInfo.userId() {
- atomic return resId;
+ atomic {
+ if(state != RES_BUSY)
+ return NO_RES;
+ return resId;
+ }
}
/**
*/
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;
}
}