expose timer interface supporting non-monotonic free-running counter and relative timeout
- Dominant language
- C
- Stars
- 4k
- Forks
- 1.7k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 237
Description
Currently, there are the following timer low-level interfaces:
* timer_lowerhalf_s: supports relative timeouts, does not report underlying counter (only time remaining to next timeout)
* oneshot_lowerhalf_s: supports relative timeout firing only once, stops after expiration (not free running)
* rtc_lowerhalf_s: represents an always-on (battery backed) free running monotonic timer with absolute alarms
For the purpose of generically supporting tickless system timer using a hardware timer which supports free running and a capture channel (for example, "advanced" STM32 timers) a new interface should be added. This kind of timer can technically be exposed as a rtc_lowerhalf_s but this requires handling the timer overflow internally to provide the illusion of a monotonic counter. To avoid repeating this for every possible implementation, this new interface would expose the overflow as a separate callback. Moreover, while rtc_lowerhalf_s can be used to supply system time (setting CONFIG_RTC_HIRES) it still requires supporting up_alarm_start/stop (although this could technically be done automatically using the rtc_lowerhalf_s alarm methods).
This new interface can then be used in arch_alarm.c and replace the implementation based on onehost() which currently re-starts the oneshot timer manually which is suboptimal when the hardware supports such a timer.
Let me know if you think this is a good idea or if you would prefer to expose such timers as rtc_lowerhalf_s better. In such case, we should consider removing the SCHED_TICKLESS_ALARM option since it could be replaced with CONFIG_RTC_HIRES.
Contributor guide
Assessment
This issue has not been assessed yet.