generic module SharedArbiterP() {
provides {
- interface Init;
interface Resource[uint8_t id];
interface ResourceDefaultOwner;
interface ArbiterInfo;
}
}
- command error_t Init.init()
- {
- call GrantedVector.clearAll();
- call RequestingVector.clearAll();
- return SUCCESS;
- }
-
async command error_t Resource.request[uint8_t id]()
{
/* The Resource docs do not say what happens when a user calls
async command error_t ResourceDefaultOwner.release()
{
- atomic {
- if (m_requesting > 0) {
- call State.forceState(S_GRANTED);
- post grantedTask();
- return SUCCESS;
- } else
- return FAIL;
- }
+ if (call State.requestState(S_GRANTED) == SUCCESS) {
+ post grantedTask();
+ return SUCCESS;
+ } else
+ return FAIL;
}
async command bool ArbiterInfo.inUse()