There's no point to clear the bit vectors in SharedArbiterP.Init.init,
because the compiler guarantees they are already clear, see BitVectorC.nc.
However, manually clearing them can create a situation where someone requesting
a shared resource has their requesting bit erased, depending upon the order of
calls to Init.init providers during boot.
ResourceDefaultOwner = SharedArbiterP;
ArbiterInfo = SharedArbiterP;
- components MainC;
- MainC.SoftwareInit -> SharedArbiterP;
-
components new BitVectorC(CLIENTS) as GrantedVectorC;
SharedArbiterP.GrantedVector -> GrantedVectorC;
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