You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mynewt.apache.org by Neel Natu <ne...@nahannisys.com> on 2016/04/07 22:59:59 UTC
Tickless operation during idle
Hi,
I just opened a pull request that implements tickless operation during idle:
https://github.com/apache/incubator-mynewt-core/pull/34
The motivation is to reduce power consumption by putting the CPU to sleep
when the OS does not have any useful work to do. At the moment the power
saving only extends to the CPU but hopefully this provides a foundation to
add off-cpu peripherals and i/o going forward.
If you have any comments let me know and we can iterate on the patch.
best
Neel
Re: Tickless operation during idle
Posted by Neel Natu <ne...@nahannisys.com>.
Hi,
Sterling asked me to go into a bit of detail about the implementation so
here goes:
When the idle task is running it is an indication that there isn't any
useful
work to be done at this time.
Useful work can be created by:
1. an interrupt requesting service OR
2. when tasks scheduled in the future are now runnable.
With respect to (1) there isn't any way for the OS to know when an interrupt
might be activated. However with respect to (2) the OS certainly knows how
long until a particular task awakens or how long until a callout handler
needs to run.
The APIs 'os_sched_wakeup_ticks()' and 'os_callout_wakeup_ticks()' return
the number of ticks until the earliest task or callout become active. These
APIs are used by 'os_idle_task()' to determine whether to transition from
periodic to tickless mode. The OS will transition to tickless mode if there
is no useful work for at least 100 msec (arbitrary). The idle task also
imposes a limit on how long the cpu remains in tickless mode (currently set
to 10 minutes, also arbitrary).
The transition to/from tickless mode is done by the MCU-specific function
'os_tick_idle(idleticks)'. Typically it will set up a one-shot timer to wake
up the CPU after a duration equivalent to 'idleticks' has elapsed. Finally,
it enters a low power idle state using a CPU-specific mechanism. For e.g.
ARM processors use the 'WFI' instruction for this purpose.
Note that 'os_tick_idle()' is an advisory API:
- it may return immediately without doing anything
- it may not transition into tickless mode
- it may transition to tickless mode but return before 'idleticks' have
elapsed
The only guarantee made by 'os_tick_idle()' is that it will sleep for no
more
than 'idleticks' and that the OS time is up-to-date when it returns.
A related change is to define 'OS_TICKS_PER_SEC' in MCU-specific header
file.
This is needed because the capabilities of the underlying periodic timer
dictate the appropriate timer frequency.
best
Neel
On Thu, Apr 7, 2016 at 1:59 PM, Neel Natu <ne...@nahannisys.com> wrote:
> Hi,
>
> I just opened a pull request that implements tickless operation during
> idle:
> https://github.com/apache/incubator-mynewt-core/pull/34
>
> The motivation is to reduce power consumption by putting the CPU to sleep
> when the OS does not have any useful work to do. At the moment the power
> saving only extends to the CPU but hopefully this provides a foundation to
> add off-cpu peripherals and i/o going forward.
>
> If you have any comments let me know and we can iterate on the patch.
>
> best
> Neel
>