From ae1731210dfbe70664270127fb5a1ffe6cc54e7c Mon Sep 17 00:00:00 2001 From: wangchengdong Date: Wed, 25 Feb 2026 09:37:13 +0800 Subject: [PATCH] sched/clock: fix CLOCK_BOOTTIME and CLOCK_MONOTONIC handling The current implementation retrieves time from the same source for both CLOCK_BOOTTIME and CLOCK_MONOTONIC, which is incorrect. CLOCK_BOOTTIME includes time spent in system suspend, whereas CLOCK_MONOTONIC does not. This patch fixes the incorrect clock source handling and ensures the two clocks are distinguished properly. Signed-off-by: Chengdong Wang --- sched/clock/clock_gettime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sched/clock/clock_gettime.c b/sched/clock/clock_gettime.c index 198b88c59ba..a154a52c835 100644 --- a/sched/clock/clock_gettime.c +++ b/sched/clock/clock_gettime.c @@ -97,7 +97,7 @@ int nxclock_gettime(clockid_t clock_id, FAR struct timespec *tp) return -EINVAL; } - if (clock_id == CLOCK_MONOTONIC || clock_id == CLOCK_BOOTTIME) + if (clock_id == CLOCK_MONOTONIC) { /* The the time elapsed since the timer was initialized at power on * reset, excluding the time that the system is suspended.