X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=doc%2Fhtml%2Ftep115.html;h=de3c6547504eb09a5f942038ce09fed57294c9e5;hb=e9bfab607e051bae6afb47b44892ce37541d1b44;hp=09830d6bea39682f6ad99528f1b04459e98c0171;hpb=e375f4f25e4f47409d09d6a13f57aff159c20886;p=tinyos-2.x.git diff --git a/doc/html/tep115.html b/doc/html/tep115.html index 09830d6b..de3c6547 100644 --- a/doc/html/tep115.html +++ b/doc/html/tep115.html @@ -41,11 +41,6 @@ blockquote.epigraph { dd { margin-bottom: 0.5em } -/* Uncomment (& remove this text!) to get bold-faced definition list terms -dt { - font-weight: bold } -*/ - div.abstract { margin: 2em 5em } @@ -296,20 +291,11 @@ ul.auto-toc { Type:Documentary Status: -Draft +Final TinyOS-Version:2.x Author: Kevin Klues, Vlado Handziski, Jan-Hinrich Hauer, Phil Levis -Draft-Created:11-Jan-2006 - -Draft-Version:1.1.2.4 - -Draft-Modified:2006-09-19 - -Draft-Discuss:TinyOS Developer List -<tinyos-devel at mail.millennium.berkeley.edu> -
@@ -326,127 +312,141 @@ of this memo is unlimited. This memo is in full compliance with TEP

1. Introduction

-

The energy resources on a typical TinyOS platform are limited, so -every effort should be made to put all devices on a given platform -into their lowest possible power-consumption states as often as -possible. Depending on the device type, selecting the correct -power-consumption state could be as simple as switching between on and -off states, or could involve selecting the optimum state from among -several. Choosing the best power-consumption state requires making -tradeoffs between various factors such as power consumption, fidelity, -performance, and wake-up latency.

-

Because of the large difference in the number of supported power- -consumption states that could potentially be present on any given -device, as well as the complexity in keeping track of the state -information needed for safe execution of any sort of system wide -power-control algorithm, a unified power management strategy for all -devices on all possible platforms is simply infeasible. Developing -such a solution would most likely be overly complex and in some cases -even suboptimal. TinyOS 2.x, therefore, takes the approach of -defining several different classes of devices for which several -different power-management strategies have been optimized. [TEP112], -for example, details how TinyOS 2.x manages the multiple power- -consumption states for microcontrollers. This document, in turn, -details the support for managing the physical and dedicated and -physical and shared device classes as defined in [TEP108]. Devices -belonging to these classes often have only two power consumption -states (on and off), and can therefore be treated differently than -devices that have multiple power consumption states. Additionally, it -turns out that, in practice, TinyOS software often just uses the two -most useful of the many power states in these cases.

-

Various policies can be implemented on top of these two classes of -devices that decide exactly when a device should be powered on or off. -For physical and shared devices, for example, a power management -policy could be written that explicitly powers a device on and off -whenever the higher level component that uses it no longer requires -it. Another policy, however, might decide to defer the power down of -the device for a a few milliseconds if its wake-up time is large -enough and it is likely that the device will be needed again sometime -in the near future. A similar set of policies could be implemented -for physical and shared devices, except that an attempt to power -down such a device would not occur until all components using it had -signalled that they no longer needed it. Providing these sorts of -policies cause devices belonging to one of these two classes to become -virtualized in the sense that their power states are automatically -handled. Any higher level components connecting to one of these -virtual devices need only signify when they require the use of the -device and when they don't. The time at which the device actually -becomes powered on or off, is left up to the power managment policy -being used.

-

In order to provide the building blocks for implementing such power -managment policies on top of physical and dedicated and physical -and shared devices, TinyOS 2.x defines two different power management -models that devices belonging to one of these two classes must adhere -to: the explicit power management model and the implicit power -management model.

+

TinyOS platforms have limited energy. A unified power management +strategy for all devices and peripherals is not feasible, as +they vary significantly in warm-up times, power profiles, and +operation latencies. While some devices, such as +microcontrollers, can efficiently calculate their lowest possible +power state very quickly, others, such as sensors with warm-up +times, require external knowledge to do so.

+

In TinyOS 1.x, applications are responsible for all power management. +Low-level subsystems, such as an SPI bus, are explicitly powered on +and off by higher level abstractions. This approach of deep calls +to StdControl.start() and StdControl.stop() introduces strange behaviors +and can get in the way of power conservation. Turning off the radio +on the Telos platform, for example, turns off the SPI bus and therefore +prevents the flash driver from working. Additionally, the microcontroller +stays in a higher power state for the SPI bus even when it is +inactive.

+

TinyOS 2.x defines two classes of devices for power-management: +microcontrollers and peripherals. TEP 112 documents how TinyOS 2.x +manages the power state of a microcontroller [TEP112]. +Unlike microcontrollers, which typically have several power states, +peripheral devices typically have two distinct states, on and off. +This TEP is dedicated to documenting how TinyOS 2.x controls the power +state of peripheral devices.

+

The term "peripheral device" refers to any hardware device which +arbitrates access with the mechanisms described in [TEP108] . These +devices are not virtualised in the sense that access to +them must be explicitly requested and released by their users.

2. Power Management Models

-

The explicit power management model provides a means for explicitly -controlling the power state of a physical device by some higher level -component. Whenever this higher level component tells the device to -power up or down it does so without delay. This model can be -particularly useful when the control information driving the selection -of the proper power state of a device is external to that device.

-

The implicit power management model, on the other hand, provides a -means for allowing the power state of a device to be controlled from -within the device itself. Devices following this model are never -explicitly powered up or down by some external component, but rather -require some policy to be defined that decides exactly when their -power states should be changed. This policy could exist natively on -the hardware of the physical device itself, or be implemented on top -of some lower level abstraction of the physical device which adheres -to the explicit power management model.

-

Just like in TinyOS 1.x, StdControl and SplitControl interfaces have -been defined by TinyOS 2.x (along with a third interface, -AsyncStdControl) in order to control the on and off states of devices -that follow the explicit power management model. One of these three -interfaces SHOULD be provided by any component wrapping a hardware -device that supports switching between an on and off state. The -selection of the right interface depends on the latencies involved in -changing between these two power states as well as the nature of the -code (sync or async) executing any of the interfaces commands.

-

Devices implemented according to the implicit power management -model, on the other hand, MAY expose one of these three interfaces, -but they are not required to do so. Virtual abstractions of physical -and dedicated devices that implement power management policies -according to this model, will indeed provide one of the three -derivatives of the StdControl interface. The interface provided will -no longer be used to explicitly power the device on and off, but -rather allow the power management policy to determine whether the -dedicated user of the device requires the device to be powered or not. -It will then make its own decision as to which state to put the device -in.

-

For physical and shared devices, the information required to -determine if one of its many users require it to be powered or not can -be inferred through information provided by the Resource interface -they provide. Because of this, no StdControl-like interface needs to -be provided, and the power management policy can act accordingly -whenever users request of release the device.

+

There are two different models to managing the power state of a +peripheral in TinyOS: explicit power management and implicit +power management.

+

The explicit model provides a means for a single client to manually +control the power state of a dedicated physical device (as defined by +[TEP108]). Whenever this client tells the device to power up or down +it does so without delay (except for delays in the hardware of course). +This model +can be particularly useful when the control information driving the +selection of the proper power state of a device relies on external +logic contained in higher level components. The following section +discusses the StdControl, SplitControl, and +AsyncStdControl interfaces used to perform power management of +this type.

+

The implicit model, on the other hand, provides a means for allowing +the power state of a device to be controlled from within the driver +for that device itself. Device drivers following this model are never +explicitly powered up or down by some external client, but rather +require some internal policy to be defined that decides exactly when +their power states should be changed. This policy could exist +natively on the hardware of the physical device itself, or be +implemented on top of some lower level abstraction of a physical +device adhering to the explicit power management model.

+

Shared devices (as defined by [TEP108]) can infer whether they +should be on or off based on the interfaces they provide to their +clients. For example, when a client requests the ADC, this implies +the ADC should be on; if there are no requests of the ADC, this implies +it should be off. Therefore shared devices do not need to provide a +power control interface. They can use an implicit power management policy. +Section 4.2 discusses this in more detail.:

+
+               /|\                                    /|\
+                |                                      |
+          Data Interface                            Resource
+                |                                      |
+-----------------------------------------------------------------------
+|             Shared Device (implicitly power managed)                |
+-----------------------------------------------------------------------
+               /|\                                    /|\
+                |                                      |
+          Data Interface                            Resource
+                |                                      |
+                |        ----------------------        |
+                |        |    Power Manager   |        |
+                |        ----------------------        |
+                |          /|\            /|\          |
+                |           |              |           |
+                |      StdControl ResourceDefaultOwner |
+                |           |              |           |
+---------------------------------      --------------------------------
+|        Dedicated Device       |      |            Arbiter           |
+|  (explicitly power managed)   |      |                              |
+---------------------------------      --------------------------------
+
+
+
+

3. Explicit Power Management

+

Just as in TinyOS 1.x, TinyOS 2.x has StdControl and SplitControl +interfaces in order to control the on and off +power states of explicitly managed peripherals. TinyOS 2.x also +introduces a third interface, AsyncStdControl. A component +representing a hardware device that can be powered on and off MUST +provide one of these three interfaces. +The selection of the right interface depends on the +latencies involved in changing between these two states as well as the +nature of the code (sync or async) executing any of the interface's +commands.

-

2.1 Explicit Power Management using StdControl

-

When a devices powerup and powerdown times are negligible, they SHOULD -provide the StdControl interface as defined below:

+

3.1 Power Management with StdControl

+

Whenever the powerup and powerdown times of a non-virtualised device +are negligible, they SHOULD provide the StdControl interface as +defined below:

 interface StdControl {
   command error_t start();
   command error_t stop();
 }
 
+
+

Note

+

Powerup and powerdown times on the order of a few microseconds have +traditionally been considered negligible, and can be waited on using +one of the BusyWait interfaces described in [TEP102]. Powerup +and powerdown times on the order of a few milliseconds, however, +should not be ignored, and MUST be hidden behind the use of the +SplitControl interface described later on in this section. +A general rule of thumb is that if waiting for powerup takes +more than one hundred microseconds, SplitControl is probably more +suitable.

+

An external component MUST call StdControl.start() to power a device on and StdControl.stop() to power a device off. Calls to -either command return SUCCESS or FAIL.

+either command MUST return either SUCCESS or FAIL.

Upon the successful return of a call to StdControl.start(), a -device MUST be completely powered, and calls to commands of other -interfaces implemented by the device abstraction CAN succeed.

+device MUST be completely powered on, allowing calls to commands of other +interfaces implemented by the device to succeed.

Upon the successful return of a call to StdControl.stop(), a -device MUST be completely powered down, and any subsequent operation -requests through calls to commands of other interfaces implemented by -that device abstraction MUST return FAIL or EOFF.

+device MUST be completely powered down, and any calls to commands +of other interfaces implemented by that device that actually access +the device hardware MUST return FAIL or EOFF.

If a device is not able to complete the StdControl.start() or -StdControl.stop() requests for any reason, they MUST return FAIL.

-

Based on these specifications, this matrix describes the valid return -values of calls based on the compoenent's power state:

+StdControl.stop() request for any reason, it MUST return FAIL.

+

Based on these specifications, the following matrix has been created +to describe the valid return values for any call made through the +StdControl interface in one of the devices valid power states:

@@ -455,8 +455,8 @@ values of calls based on the compoenent's power state:

- - + + @@ -474,8 +474,7 @@ values of calls based on the compoenent's power state:

CallOnOffDevice OnDevice Off
-

Devices adhereing to this power management model would provide this -interface as shown below:

+

Devices providing this interface would do so as shown below:

 configuration DeviceC {
   provides {
@@ -487,9 +486,9 @@ configuration DeviceC {
 
-

2.2 Power Management with SplitControl

-

When a devices powerup and powerdown times are non-negligible, the -SplitControl interface MUST be used in place of the StdControl +

3.2 Power Management with SplitControl

+

When a device's powerup and powerdown times are non-negligible, the +``SplitControl`` interface SHOULD be used in place of the ``StdControl`` interface. The definition of this interface can be seen below:

 interface SplitControl {
@@ -501,55 +500,81 @@ interface SplitControl {
 

An external component MUST call SplitControl.start() to power a device on and SplitControl.stop() to power a device off. Calls to -either command return one of SUCCESS, FAIL, or EBUSY.

-

Successful calls to SplitControl.startDone() MUST signal one of -SplitControl.startDone(SUCCESS) or -SplitControl.startDone(FAIL).

-

Successful calls to SplitControl.stopDone() MUST signal one of +either command return one of SUCCESS, FAIL, EBUSY, or +EALREADY. SUCCESS indicates that the device has now started changing +its power state and will signal a corresponding completion event in +the future. EBUSY indicates that the device is in the midst of either starting +or stopping (e.g., it is starting when stop is called or stopping +when start is called) and will not issue an event. EALREADY indicates +that the device is already in that state; the call is erroneous and a +completion event will not be signaled. FAIL indicates that the +device's power state could not be changed. More explicitly:

+

Successful calls to SplitControl.start() MUST signal one of +SplitControl.startDone(SUCCESS) or SplitControl.startDone(FAIL).

+

Successful calls to SplitControl.stop() MUST signal one of SplitControl.stopDone(SUCCESS) or SplitControl.stopDone(FAIL).

-

Upon signalling either a SplitControl.startDone(SUCCESS) or a -SplitControl.stopDone(FAIL) event, a device MUST be completely -powered, and operation requests through calls to commands of other -interfaces implemented by the device abstraction SHOULD succeed.

-

Upon signalling either a SplitControl.stopDone(SUCCESS) or a -SplitControl.startDone(FAIL) event, a device MUST be completely -powered down, and any subsequent calls to commands of other interfaces -implemented by the device abstraction MUST return EOFF or FAIL.

+

Upon signaling a SplitControl.startDone(SUCCESS), a device MUST +be completely powered on, and operation requests through calls to commands +of other interfaces implemented by the device MAY succeed.

+

Upon signalling a SplitControl.stopDone(SUCCESS), a device MUST be +completely powered down, and any subsequent calls to commands of other +interfaces implemented by the device that actually access +the device hardware MUST return EOFF or FAIL.

+

If a device is powered on and a successful call to SplitControl.stop() +signals a SplitControl.stopDone(FAIL), the device MUST still be fully +powered on, and operation requests through calls to commands of other +interfaces implemented by the device MAY succeed.

+

If a device is powered down and a successful call to SplitControl.start() +signals a SplitControl.startDone(FAIL), the device MUST still be fully +powered down, and operation requests through calls to commands of other +interfaces implemented by the device MUST return EOFF or FAIL.

If a device is not able to complete the SplitControl.start() or -SplitControl.stop() requests for any reason, they MUST return -FAIL.

-

Calls to either StdControl.start() or StdControl.stop() while -a start or top operattion is pending MUST return an EBUSY.

+SplitControl.stop() requests they MUST return FAIL.

+

Calls to either SplitControl.start() when the device is starting +or SplitControl.stop() while the device is stopping MUST return +SUCCESS, with the anticipation that a corresponding +SplitControl.startDone() or SplitControl.stopDone() +will be signaled in the future.

+

Calls to SplitControl.start() when the device is started +or SplitControl.stop() while the device is stopped MUST +return EALREADY, indicating that the device is already in that +state. The corresponding completion event (startDone for start +or stopDone for stop) MUST NOT be signaled.

+

Calls to SplitControl.start() when the device is stopping or +SplitControl.stop() while the device is starting MUST return +EBUSY, indicating that the device is busy performing a differnet +operation. The correspodning completion event (startDone for start or +stopDone for stop) MUST NOT be signaled.

-+++-- - - + + - + - + - - + + @@ -564,8 +589,7 @@ EOFF
CallOnOffDevice OnDevice Off Starting Stopping
SplitControl.start()SUCCESSEALREADY SUCCESS FAILEBUSYSUCCESS EBUSY
SplitControl.stop() SUCCESS FAILSUCCESSEBUSYEALREADY EBUSYSUCCESS
operation depends
-

Devices adhereing to this power management model would provide this -interface as shown below:

+

Devices providing this interface would do so as shown below:

 configuration DeviceC {
   provides {
@@ -575,15 +599,36 @@ configuration DeviceC {
   }
 }
 
+
+

Note

+

Other approaches were considered for the return values of +SplitControl.start() and SplitControl.stop(). One such +approach would have replaced EBUSY with SUCCESS when +SplitControl.start() was called while in the process of stopping +and SplitControl.stop() was called while in the process of starting. +However, implementing such an approach adds unwanted complexity to +a device driver. It is unreasonable to expect the implementor of +each driver to implement this functionality.

+

Returning EBUSY is the most straightforward, unambiguous value +that can be returned in such a situation. By returning +EBUSY when a device is in a transitional state, the components +built on top of a driver unambiguously know exactly why a call to +start() or stop() did not succeed, and can take action accordingly. +Since only ONE component should ever implement the SplitControl +interface for a given device, it isn't unreasonable to expect them +to keep track of this return value themselves. There is, of course, +nothing preventing someone from creating a component +on top of each driver implementation that implements things differently.

+
-

2.3 Power Management with AsyncStdControl

-

The commands and the events of the StdControl and the SplitControl +

3.3 Power Management with AsyncStdControl

+

The commands and the events of the ``StdControl`` and the ``SplitControl`` interfaces are synchronous and can not be called from within asynchronous code (such as interrupt service routines, etc.). For the cases when the power state of the device needs to be controlled from -within asynchronous code, the AsyncStdControl interface MUST be used -in place of the StdControl interface. The definition of this +within asynchronous code, the ``AsyncStdControl`` interface MUST be used +in place of the ``StdControl`` interface. The definition of this interface can be seen below:

 interface AsyncStdControl {
@@ -591,10 +636,9 @@ interface AsyncStdControl {
   async command error_t stop();
 }
 
-

All of the semantics that held true for devices providing the -StdControl interface also hold for this interface.

-

Devices adhereing to this power management model would provide this -interface as shown below:

+

All of the semantics that hold true for devices providing the +StdControl interface also hold for this interface.

+

Devices providing this interface would do so as shown below:

 configuration DeviceC {
   provides {
@@ -603,148 +647,134 @@ configuration DeviceC {
     ....
   }
 }
-
-
-.. Note::
-
-Determining exactly when to use the AsyncStdControl interface
-instead of simply posting a task and using the StdControl interface
-can be tricky.  One must consider the advantages and disadvantages
-of using one interface over the other.  How complex is the code
-being I am trying to execute?  Do I really want to execute all of
-my startup code in async context?  Do I gain some performance in
-terms of startup latency or code size if I run my startup code in
-async context?  These are just a few of the factors that need to be
-considered when making this decision, and unfortunately there just
-is no easy answer. Note that a component with an AsyncStdControl
-cannot call SplitControl or StdControl. In practice, AsyncStdControl
-is used for low-level hardware resources.
 
+
+

Note

+

The AsyncStdControl interface should be provided whenever it might be +necessary to allow a device to be powered on or off while running in +async context. If it is anticipated that a device will not (or more +likely should not) be powered on or off while in asynchronous context, +then the StdControl interface SHOULD be provided instead. Components +that wish to power the device on or off from within async context would +then be required to post a task before doing so. In practice, +AsyncStdControl is provided by low-level hardware resources, while +StdControl is provided by higher level services built on top of these +resources.

+
-

3. Power management policies

-

While the explicit power management model provides the basic means -for controlling the power state of the device, it is void of any -policy about who, when, or how the power of the device should be -managed. This does not represent a large problem for the simple case -of physical and dedicated devices, but can become crucial for -non-trivial cases involving complex interdependencies between devices -being controlled by multiple users.

-

For example, if component A is using two devices, B and C, -what happens with B and C when one calls StdControl.stop() on -the top component A? The above problem has its dual in the case of -shared devices. Assuming that device A is shared by components B -and C, the question exists as to when device A can be powered -down?

+

4. Implicit Power Management

+

While explicit power management provides the mechanism for changing +power states, it does not specify a policy. +This does not represent a large problem for the simple case +of dedicated devices, but can become crucial for non-trivial cases +involving complex interdependencies between devices controlled by multiple +clients.

+

For example, if component A is a client of both component B +and component C, what happens with B and C if +StdControl.stop() is called on component A ? Should components +B and C also be stopped? What about the reverse case where both +B and C are clients of the single shared component, A? If +devices B and C are shut off, should A be shut off as well? +How can one decide when it is appropriate to cascade such powerup +and powerdown requests?

The complex nature of the problem is evident from the number of -unexpected behaviors in TinyOS 1.x involving StdControl. On several +unexpected behaviors in TinyOS 1.x involving StdControl. On several platforms, one of the SPI buses is shared between the radio and the flash device. On some of them, issuing StdControl.stop() on the -radio results in a cascaded SPI bus becoming disabled, rendering the -communication with the flash impossible. Of course, the right policy -would involve tracking the users of the SPI bus and powering it off -only once both the radio and the flash devices wer no longer using -it. Conversely, the SPI bus should be powered on whenever there is at -least one active user.

-

The selection of the right policy is a complex task that depends on -the nature of the devices, their interdependency, as well as on the -application requirements. For the cases when some of these features -are known a-priori or are restricted in some sense, it is preferable -that the system provide architectural support for enforcing a -meaningful default power-management policy instead of simply passing -the task to the application programmer to be solved on a case-by-case -basis.

-

TinyOS 2.x provides two contexts of restricted resource -interdependency where such a default power-management policy can be -offered. For physical and shared resources (defined in [TEP108]) -(and covered by the Hardware Abstraction Architecture [TEP2]), TinyOS -2.x provides a flexible implicit power management model that is -tightly coupled with the arbiter concept and uses the basic -mechanisms offered by the explicit power management scheme.

+radio results in a series of cascaded calls that result in SPI bus +becoming disabled, rendering the communication with the flash impossible. +Of course, the right policy would involve tracking the clients of the +SPI bus and powering it off only once both the radio and the flash +devices were no longer using it. Conversely, the SPI bus should be +powered on whenever there is at least one active client.

+

The selection of the right power management policy to use is a complex +task that depends on the nature of the devices in use, their +interdependency, as well as on any specific application requirements. +For cases when some of these features are known a-priori or are +restricted in some sense, it is preferable that the system provide +architectural support for enforcing a meaningful default power-management +policy instead of passing that task on to the application programmer to be +solved on a case-by-case basis. The following section discusses these power +management policies and the components that implement them in greater detail.

-

4. Implicit Power Management for Physical and Shared Resources

-

The physical and shared resource class defined in Section 2.3 of -[TEP108], provides a well defined component interdependency, where a -single resource is shared among multiple clients. This relationship -enables definition of a simple default power-management policy that -powers the resource off when no potential users are waiting for access -to the resource. Conversely, the resource is powered on whenever a -client requests its use. When the resource being controlled happens -to be an actual physical device, the implicit power management model -for physical devices as described in section two applies.

-

The realization of a specific power-control policy for shared reources -does not need to be resource specific. Just as generic arbiters are -offered in TinyOS 2.x to provide the arbitration functionality -required by shared resources, generic power management policies are -also offered to allow the power management of devices to be automated.

-

The PowerManager component implementing one of these polices acts as -the lowest-priority user of the shared resource. In contrast to -"normal" clients, the PowerManager interacts with the resource -arbiter using the richer ResourceController interface:

+

4.1. Power Management Policies

+

Just as generic arbiters are offered in TinyOS 2.x to provide the +arbitration functionality required by shared resources, generic power +management policies are also offered to allow the power management of +non-virtualised devices to be automatically controlled.

+

Through the use of the arbiter components described in [TEP108], +device drivers implemented as shared resources provide the type of +restricted resource interdependency where default power-management +policies can be offered. The shared resource class defined in Section +2.3 of [TEP108], provides a well defined component interdependency, +where a single resource is shared among multiple clients. This +relationship enables the definition of default power-management +policies that can be used to automatically power the resource on and +off.

+

The Power Manager component implementing one of these polices acts as +the default owner of the shared resource device and interacts with it +through the use of the ResourceDefaultOwner interface:

-interface ResourceController {
-    async command error_t request();
-    async command error_t immediateRequest();
-    event void granted();
-    async command void release();
-    async event void requested();
-    async event void idle();
+interface ResourceDefaultOwner {
+  async event void granted();
+  async command error_t release();
+  async command bool isOwner();
+  async event void requested();
+  async event void immediateRequested();
 }
 
-

Acting as a lowest priority client, the Power Manager waits for the -ResourceController.idle() event to be signalled before trying to -gain ownership over the resource. It does so using the -ResourceController.immediateRequest() command in order to gain -control of the resource as quickly as possible.

-

Once it owns the resource, the PowerManager is free to execute its -power-management policy using the mechanisms provided by the resource -via the explicit power-management model. Different managers can -implement different policies. In the simplest case, this would involve -an immediate power-down via one of the .stop() commands. When the -power-state transition involves non-negligible costs in terms of -wake-up latency or power consumption, the PowerManager might revert -to a more intelligent strategy that tries to reduce these effects. -One strategy might involve using a delayed power-down timer to defer -the powers-down of a resource to some later point in time unless some -normal-priority client requests the device in the meantime.

-

Regardless of the power-off policy, the PowerManager remains owner -of the resource as long as the resource is not requested by a normal -user. When one of these "normal" users finally makes a request, the -PowerManager component will receive a -ResourceController.requested() from the arbiter it is associated -with. Upon receiving this event, the PowerManager MUST power the -resource back on (in case it was powered-off) through one of the -explicit power-management interfaces provided by the lower level -abstraction of the physical device. The PowerManager can release the -ownership of the resource (using the ResourceController.release() -command) ONLY after the resource has been fully powered-on.

+

Acting as the default owner, the Power Manager waits for the +ResourceDefaultOwner.granted() event to be signaled in order to +gain ownership over the resource device.

+

Once it owns the device, the Power Manager is free to execute its +power-management policy using the StdControl-like interface provided by the +underlying resource. Different power managers can implement different +policies. In the simplest case, this would involve an immediate power-down +via one of the stop() commands. When the power-state transition +involves non-negligible costs in terms of wake-up latency or power +consumption, the PowerManager might revert to a more intelligent +strategy that tries to reduce these effects. As pointed out in the +introduction, one such strategy might involve the use of a timer to defer +the power-down of the resource to some later point in time, giving any +resource clients a window of opportunity to put in requests before the +device is fully shut down.

+

Regardless of the power management policy in use, the Power Manager +remains owner of the resource as long as the resource is not requested +by one of its clients. Whenever a client puts in a request, the +Power Manager will receive a ResourceDefaultOwner.requested() event +(or immediateRequested() event) from the arbiter it is associated with. +Upon receiving this event, the Power Manager MUST power up the +resource through the StdControl-like interface provided by the lower level +abstraction of the physical device. The Power Manager MUST release the +ownership of the resource (using the ResourceDefaultOwner.release() +command) and MUST wait until after the resource has been fully powered on +before doing so.

Modeling devices as shared resources and allowing them to be controlled in the way described here, solves the problems outlined in -section 3 regarding how to keep track of who, when, and how the -powerdown of nested resources should proceed. The PowerManager -component answers the question of who, the combination of the power +section 3 regarding how to keep track of when and how the +powerdown of nested resources should proceed. The Power Manager +component answers the question of how, and the combination of the power management policy being used and the reception of the -ResourceController.idle() and ResourceController.requested() -events answers the question of when, and through one of the explicit -power-management interfaces provided by the lower level abstraction -of the physical device answers how. As long as the device resource at -the bottom of a large set of nested resource users is released at the -proper time, the power mananger will ba ble to power down its device -appropriately.

-

Using the model described above, a device resource that follows the -implicitly powere management model could be built as shown below:

+ResourceDefaultOwner.granted() and ResourceDefaultOwner.requested() +events answers the question of when. As long as the resource at +the bottom of a large set of nested resource clients has been fully released, +the power mananger will be able to power down the resource appropriately.

+

Using the model described above, a resource that uses one of these policies +according to the implicitly power management model could be built as shown below:

 module MyFlashP {
   provides {
     interface Init;
     interface SplitControl;
     interface Resource;
+    interface FlashCommands;
     ...
   }
 }
 implementation {
-...
+  ...
 }
 
 generic module PowerManagerC(uint8_t POWERDOWN_DELAY) {
@@ -753,63 +783,99 @@ generic module PowerManagerC(uint8_t POWERDOWN_DELAY) {
   }
   uses {
     interface SplitControl;
-    interface ResourceController;
+    interface ResourceDefaultOwner;
   }
 }
 implementation {
-...
+  ...
 }
 
 #define MYFLASH_RESOURCE "MyFlash.resource"
+#define MYFLASH_POWERDOWN_DELAY       1000
 configuration MyFlashC {
   provides {
     interface Init;
     interface Resource;
+    interface FlashCommands;
   }
 }
 implementation {
   components new PowerManagerC(MYFLASH_POWERDOWN_DELAY)
-           , FcfsArbiter(MYFLASH_RESOURCE)
-           , MyFlashP;
+  , FcfsArbiter(MYFLASH_RESOURCE)
+  , MyFlashP;
 
   Init = MyFlashP;
   Resource = FcfsArbiter;
+  FlashCommands = MyFlashP;
 
-  PowerManagerC.ResourceController -> FcfsArbiter;
+  PowerManagerC.ResourceDefaultUser -> FcfsArbiter;
   PowerManagerC.SplitControl -> MyFlashP;
+
 }
 

This example implementation is built out of three components. The -first component (MyFlashP) follows the explicit power management +first component (MyFlashP) follows the explicit power management model for defining the interfaces to the physical flash device. The -second component (PowerManagerC) is the generic powermanager +second component (PowerManagerC) is the generic Power Manager component that will be used to implement the specific power management -policy for this device. The third component (MyFlashC) is the +policy for this device. The third component (MyFlashC) is the configuration file that wires together all of the components required -by the implementation of device adhereing to the implicit power -management model. It includes the MyflashP and PowerManagerC -components, as well as an arbiter component for managing shared users -of the device. Notice how the powermanager is wired to both the -resourcecontroller interface provided by the arbiter, and the -SplitControl interface provided by the flash. All normal users of the -resource are directly connected to the resource interface provided by -the arbiter. As outlined above, the PowerManagerC component will use -the events signalled through the ResourceController interface from the -arbiter to determine when to make calls to the commands provided by -the SplitControl interface coming from the FlashP component in order -to power it up and power it down.

-
+by the implementation of of the device as it adheres to the implicit power +management model. It includes the MyflashP and PowerManagerC +components, as well as an arbiter component for managing shared clients +of the device. Notice how the Power Manager is wired to both the +ResourceDefaultUser interface provided by the arbiter, and the +SplitControl interface provided by the flash. All clients of this flash +device are directly connected to the resource interface provided by +the arbiter. As outlined above, the PowerManagerC component will use +the events signaled through the ResourceDefaultUser interface to determine +when to make calls to power the device up and power it down through +the SplitControl interface.

-

5. Sample Power Managers: PowerManagerC and DeferredPowerManagerC

-

TinyOS 2.x currently has two sample power management policies in -lib/power. Each policy has three implementations: StdControl, -SplitControl, and AsyncStdControl. The two policies are immediate -and deferred. T

+

4.2. Example Power Managers: PowerManagerC and DeferredPowerManagerC

+

TinyOS 2.x currently has two default power management policies +that it provides. These policies are implemented by the various +components located under tinyos-2.x/lib/power. The first policy +is implemented using an immediate power control scheme, whereby +devices are powered on and off immediately after they have been +requested and released. The second policy is implemented using +a deferred power control scheme, whereby devices are powered +on immediately after being requested, but powered off after +some small delay from being released. This delay is configurable +to meet the varying needs of different device drivers.

+

Each policy has three different implementations for use by each of +the StdControl, SplitControl, and AsyncStdControl +interfaces.

+

For reference, each of the available components are listed below

+
+
Immediate Power Management:
+
    +
  • StdControlPowerManagerC
  • +
  • SplitControlPowerManagerC
  • +
  • AsyncStdControlPowerManagerC
  • +
+
+
Deferred Power Management:
+
    +
  • StdControlDeferredPowerManagerC
  • +
  • SplitControlDeferredPowerManagerC
  • +
  • AsyncStdControlDeferredPowerManagerC
  • +
+
+
+
-

6. Author's Address

+

5. Author's Address

+
Kevin Klues
+
444 Gates Hall
+
Stanford University
+
Stanford, CA 94305-9030
+

+ +

Vlado Handziski
Sekr FT5
Einsteinufer 25
@@ -819,14 +885,6 @@ and deferred. T

phone - +49 30 314 23831

-
Kevin Klues
-
503 Bryan Hall
-
Washington University
-
St. Louis, MO 63130
-

-
phone - +1-314-935-6355
- -

Jan-Hinrich Hauer
Sekr FT5
Einsteinufer 25
@@ -847,16 +905,16 @@ and deferred. T

6. Citations

- +
- +
[TEP2]TEP 2: Hardware Abstraction Architecture.
[TEP102]TEP 102: Timers.
- +
[TEP108](1, 2) TEP 108: Resource Arbitration.
[TEP108](1, 2, 3, 4, 5) TEP 108: Resource Arbitration.