Comtrol eCos User Manual
Page 660

Introduction
mode. This check happens between every power controller invocation. Usefully this makes it possible for power
controllers themselves to manipulate power modes: a power controller is invoked to change mode; for some reason
it determines that the new mode is inappropriate; it calls
power_set_mode
to move the system back to another
mode; when the power controller returns this event will be detected; the power management thread will abort the
current mode change, and start the new one.
In addition to changing the power mode for the system as a whole, individual controllers can be manipulated using
the function
power_set_controller_mode
. For example, while the system as a whole might be in active mode
certain devices might be kept in sleep mode until they are explicitly activated. It is possible to mix concurrent
calls to
power_set_mode
and
power_set_controller_mode
, and when a power controller is invoked it may use
power_set_controller_mode
to request further changes to its own or to another controller’s mode as required.
There are some scenarios where the power management package should not use its own thread. One scenario is if
the configuration is specifically for a single-threaded application such as RedBoot. Another scenario is if the policy
module already involves a separate thread: it may make more sense if the various power management operations are
synchronous with respect to the calling thread. The use of a separate thread inside the power management package
is controlled by the configuration option
CYGPKG_POWER_THREAD
, which is active only if the kernel package is
present and enabled by default.
If no separate power management thread is used then obviously the implementations of
power_set_mode
and
power_set_controller_mode
will be somewhat different: instead of waking up a separate thread to do the
work, these functions will now manipulate the power controllers directly. If the system does still involve multiple
threads then only one thread may call
power_set_mode
or
power_set_controller_mode
at a time: the power
management package will not provide any synchronization, that must happen at a higher level. However when a
power controller is invoked it can still call these functions as required.
556