nuttx/sched/clock
chao an d8b4d53444 sched/tickless: Fix CLOCK_MONOTONIC always 0 by updating sched ticks
Fix the issue where clock_gettime(CLOCK_MONOTONIC) always returns 0 in
tickless mode, caused by the scheduler tick counter (g_system_ticks) not
being updated with the actual timer ticks.

1. Add clock_update_sched_ticks() function to sched/clock/clock_sched_ticks.c:
  a. This function directly sets the system tick counter to a specific value
     (vs incrementing in clock_increase_sched_ticks), with full documentation
     matching the existing code style.
  b. Uses seqlock to ensure thread-safe access to g_system_ticks.

2. Call clock_update_sched_ticks() in nxsched_process_timer() (sched_processtickless.c):

  a. Syncs the scheduler tick counter with the actual timer ticks retrieved via up_timer_gettick().

With this fix, g_system_ticks is properly updated in tickless mode,
and clock_gettime(CLOCK_MONOTONIC) returns the correct non-zero monotonic time.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-03-03 11:01:02 -05:00
..
clock.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
clock.h sched/tickless: Fix CLOCK_MONOTONIC always 0 by updating sched ticks 2026-03-03 11:01:02 -05:00
clock_adjtime.c sched/clock: support using CLOCKFD to call clock_adjtime 2025-12-30 10:22:09 -03:00
clock_delay.c arch/delays: Invalid default value for BOARD_LOOPSPERMSEC 2026-02-25 15:00:03 -03:00
clock_getres.c sched/clock: support using CLOCKFD to call clock_getres 2025-12-30 10:22:09 -03:00
clock_gettime.c sched/clock: fix CLOCK_BOOTTIME and CLOCK_MONOTONIC handling 2026-02-25 16:15:23 +08:00
clock_initialize.c fs/timerfd: implement TFD_TIMER_CANCEL_ON_SET to detect clock changes 2026-01-30 17:20:24 +08:00
clock_notifier.c fs/timerfd: implement TFD_TIMER_CANCEL_ON_SET to detect clock changes 2026-01-30 17:20:24 +08:00
clock_perf.c arch/armv7-r: userspace PMU access 2026-02-02 16:20:39 +01:00
clock_realtime2absticks.c clock: correct compile failed 2024-09-29 18:18:01 +08:00
clock_sched_ticks.c sched/tickless: Fix CLOCK_MONOTONIC always 0 by updating sched ticks 2026-03-03 11:01:02 -05:00
clock_settime.c fs/timerfd: implement TFD_TIMER_CANCEL_ON_SET to detect clock changes 2026-01-30 17:20:24 +08:00
clock_systime_ticks.c sched/clock: Remove unnecessary preprocessor definition 2025-12-12 12:31:16 +08:00
clock_systime_timespec.c sched/clock: Improve clock implementation with sched ticks functions 2025-10-18 20:07:59 +08:00
clock_timekeeping.c fs/timerfd: implement TFD_TIMER_CANCEL_ON_SET to detect clock changes 2026-01-30 17:20:24 +08:00
clock_timekeeping.h sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
CMakeLists.txt arch/delays: Invalid default value for BOARD_LOOPSPERMSEC 2026-02-25 15:00:03 -03:00
Make.defs arch/delays: Invalid default value for BOARD_LOOPSPERMSEC 2026-02-25 15:00:03 -03:00