Commit Graph

22 Commits

Author SHA1 Message Date
Petteri Aimonen 1825f9534c adjtime: Rewrite implementation to work for RTC and tickless kernel
Previous adjtime() implementation was limited to adjusting system
timer tick period. This commit reimplements the internals to use
a kernel watchdog timer. Platform-independent part of the code now
works also for adjusting hires RTC and tickless timer rate.

User code facing API is unchanged. Architecture code API has changed:
up_adj_timer_period() is replaced by up_adjtime().

Other improvements:

- Support query of remaining adjustment by passing NULL to first
  argument of adjtime(). This matches Linux behavior.

- Improve resolution available for architecture driver, previously
  limited to 1 microsecond per tick. Now 1 nanosecond per second.
2023-11-14 19:47:40 -08:00
Michal Lenc 360e938fa6 sched: add support for adjtime() interface
This commit adds Linux like adjtime() interface that is used to correct
the system time clock if it varies from real value. The adjustment is
done by slight adjustment of clock period and therefore the adjustment
is without time jumps (both forward and backwards)

The implementation is enabled by CONFIG_CLOCK_ADJTIME and separated from
CONFIG_CLOCK_TIMEKEEPING functions. Options CONFIG_CLOCK_ADJTIME_SLEWLIMIT
and CONFIG_CLOCK_ADJTIME_PERIOD can be used to control the adjustment
speed.

Interfaces up_get_timer_period() and up_adj_timer_period() has to be
defined by architecture level support.

This is not a POSIX interface but derives from 4.3BSD, System V.
It is also supported for Linux compatibility.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-04-25 14:37:50 -03:00
Peter Bee 8a47dd95c9 sched/clock: add nsec range check in clock_settime
MIRTOS-109

Return error when tv_nsec <0 or >=1000 million.

Change-Id: Iddbbcda163cb402551f619efb7486f6798859d57
Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2021-07-09 14:19:03 -03:00
Anthony Merlino 9c8c2b0db2 Separate CLOCK_TIMEKEEPING and SCHED_TICKLESS. 2021-04-13 11:42:31 -05:00
Alin Jerpelea 8935ac4cc3 sched: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can mograte the licenses
to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08:00
Xiang Xiao 517974787f Rename clock_systime[r|spec] to clock_systime_[ticks|timespec]
follow up the new naming convention:
https://cwiki.apache.org/confluence/display/NUTTX/Naming+of+OS+Internal+Functions
2020-05-10 14:35:50 -06:00
Xiang Xiao 6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
Gregory Nutt b5111d2c38 tools/nxstyle.c: Add logic to detect if there is a blank line following the final right brace. sched/: Applied the modified nxstyle to all C file as a test. 2019-10-24 11:02:42 -06:00
Gregory Nutt 246773faa7 Rename CONFIG_SCHED_TIMEKEEPING to CONFIG_CLOCK_TIMEKEEPING. That is a better compartmentalized name. 2016-07-11 06:54:02 -06:00
Max Neklyudov 8db29071da timekeeping: initial implementation 2016-07-10 16:14:25 -06:00
Gregory Nutt 13cac3b592 sched/: Change some *err() message to *info() messages if what was a *dbg() message does not indicate and error condition. 2016-06-11 16:42:42 -06:00
Gregory Nutt a1469a3e95 Add CONFIG_DEBUG_ERROR. Change names of *dbg() * *err() 2016-06-11 15:50:49 -06:00
Gregory Nutt 720343612b Remove some empty file section section header comments 2016-02-17 18:05:03 -06:00
Gregory Nutt 6e3107650d nuttx/sched: Replace irqsave() with enter_critical_section(); replace irqrestore() with leave_critical_section() 2016-02-14 08:17:46 -06:00
Gregory Nutt 5b51a9fcdd Standardize the width of all comment boxes in C files 2015-10-02 17:43:18 -06:00
Gregory Nutt cb9e27c3b0 Standardize naming used for public data and function groupings 2015-10-02 16:30:35 -06:00
Gregory Nutt 16276a4793 Change the order of some operations to prevent a debug assertion from firing. 2015-05-18 06:34:54 -06:00
Gregory Nutt b4423c1eed Make some file section headers more consistent with standard 2015-04-08 06:47:36 -06:00
Gregory Nutt 3724a5e98e RTC: Remove all backdoor interfaces from rtc.h 2015-02-13 08:41:34 -06:00
Gregory Nutt c19659d7d2 Fixes to clock bias logic. Remove vestiges of g_tickbias; apply bias instead to g_basetime 2014-09-10 16:36:25 -06:00
Gregory Nutt eed1d6c619 When reading the system timer, don't read a struct timespec, convert it to a fake tick count, then back to a timespec. Remove CLOCK_ACTIVETIME.. it is non-standard, unused, and gets in the way of changes like this 2014-08-15 03:55:41 -06:00
Gregory Nutt d4b56eb3cc Move clock functions from sched/ to sched/clock 2014-08-08 14:43:02 -06:00