SLIDE 4 4
19
Resource Arbitration
- Coordinates use of shared resources
- ADC, system buses, timers, peripheral sensors, flash, etc.
- Performed using dedicated Arbiter components
- Can implement different policies (Fcfs, Round Robin)
- Keeps implementation of granting access to a resource separate
from implementation of using it
- Default Arbiter implementations
- Have ability to queue incoming requests
- Guarantee requests will be fulfilled using dedicated slot in queue for
each resource user (similar to default task scheduler, virtualized send service)
- Exports interfaces useful for other services (i.e. runtime checks of
- wnership, configuration, power management)
20
Resource Arbitration (con’t)
generic module ArbiterP(uint8_t controller_id) { provides { interface Resource[uint8_t id]; interface ResourceRequested[uint8_t id]; interface ResourceController; interface ArbiterInfo; } uses { interface ResourceConfigure[uint8_t id]; interface ResourceQueue as Queue; } }
interface Resource { async command error_t request(); async command error_t immediateRequest(); event void granted(); async command error_t release(); async command bool isOwner(); } interface ResourceController { async event void granted(); async command error_t release(); async command bool isOwner(); async event void requested(); async event void immediateRequested(); } interface ResourceRequested { async event void requested(); async event void immediateRequested(); } interface ArbiterInfo { async command bool inUse(); async command uint8_t userId(); } interface ResourceConfigure { async command void configure(); async command void unconfigure(); } interface ResourceQueue { async command bool isEmpty(); async command bool isEnqueued(uint8_t id); async command uint8_t dequeue(); async command error_t enqueue(uint8_t id); }
21
Resource Power Management
Power management of Peripheral devices
- Used by shared resources in conjunction with an arbiter
- Used to control power state of peripheral devices
- Use ResourceController interface provided by an arbiter to
take control of a resource when no one is using it and power it down
- Powers a resource back up when a user requests it
- Deferred vs. Non-deferred powerdown
22
Resource Power Management (con’t)
configuration MyResourceC{ provides { interface Resource[uint8_t]; interface DoStuff[uint8_t]; } } implementation { components MyResourceP, new FcfsArbiterC(unique(“MyResource”)) as Arbiter, new StdControlDeferredPowerManagerC(750) as PowerManager; Resource = Arbiter; MyResourceP.DoStuff -> DoStuff; PowerManager.StdControl -> MyResourceP.StdControl; PowerManager.ResourceController -> Arbiter.ResourceController; PowerManager.ArbiterInfo -> Arbiter.ArbiterInfo; } Used to Perform Arbitration Used to perform operations provided the resource Implements DoStuff interface for performing operations on the resource Default arbiter implementation using Fcfs queuing policy Power Manager implementation Deferring powerdown by 750 milliseconds Resource interface of MyResource exported directly from arbiter Implementation of operations to be performed on MyResource done in private module Power Control interface of MyResource provided to PowerManager Interface provided to PowerManager so it will become
- wner of resource whenever
it goes idle Interface provided to PowerManager so it can verify resource is actually idle before shutting it off
23
Resource Virtualization
Hides use of Resource interface from the user
- Allows a user to simply call commands provided by a
resource resource, rather than explicitly requesting and releasing its use
- Implementation of each command performs the request,
waits for granted to come back, then actually makes the call
- When call completes, the resource is released, and an event
is sent back to the user
- Example: ADC.read() -> ADC.readDone()
Only practical when precise timing not necessary
24
Outline
Introduction TinyOS-2.x Core Comparison to other mote OSs Critique