sched/clock: Improve CLOCK_MONOTONIC nxclock_gettime()

Improve nxclock_gettime(), to get the system time excluding
   the time that the system is suspended, when the clockid is
   CLOCK_MONOTONIC

Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
This commit is contained in:
wangchengdong 2025-10-13 20:57:43 +08:00 committed by Xiang Xiao
parent 1a22f4bf28
commit c7b6442974

View file

@ -88,10 +88,18 @@ static clock_t clock_process_runtime(FAR struct tcb_s *tcb)
void nxclock_gettime(clockid_t clock_id, FAR struct timespec *tp)
{
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.
* reset, excluding the time that the system is suspended.
*/
clock_ticks2time(tp, clock_get_sched_ticks());
}
else if (clock_id == CLOCK_BOOTTIME)
{
/* The the time elapsed since the timer was initialized at power on
* reset, including the time that the system is suspended..
*/
clock_systime_timespec(tp);