sched/hrtimer: Replace hrtimer_gettime with clock_systime_nsec.

This commit move the hrtimer_gettime to clock_systime_nsec to improve
the code reusability.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
ouyangxiangzhen
2026-01-07 20:56:55 +08:00
committed by GUIDINGLI
parent 65bc3db624
commit 89dbed25a0
4 changed files with 24 additions and 26 deletions
+22
View File
@@ -733,6 +733,28 @@ clock_t clock_systime_ticks(void);
void clock_systime_timespec(FAR struct timespec *ts);
/****************************************************************************
* Name: clock_systime_nsec
*
* Description:
* Return the current value of the system timer counter as
* uint64_t nanoseconds.
*
* Input Parameters:
* ts - Location to return the time
*
* Returned Value:
* The current system time in nanoseconds.
*
****************************************************************************/
static inline_function uint64_t clock_systime_nsec(void)
{
struct timespec ts;
clock_systime_timespec(&ts);
return clock_time2nsec(&ts);
}
/****************************************************************************
* Name: clock_cpuload
*
-24
View File
@@ -110,30 +110,6 @@ void hrtimer_process(uint64_t now);
* Inline Functions
****************************************************************************/
/****************************************************************************
* Name: hrtimer_gettime
*
* Description:
* Get the current high-resolution time in nanoseconds.
*
* Returned Value:
* Current time in nanoseconds.
****************************************************************************/
static inline_function
uint64_t hrtimer_gettime(void)
{
struct timespec ts;
/* Get current time from platform-specific timer */
clock_systime_timespec(&ts);
/* Convert timespec to nanoseconds */
return clock_time2nsec(&ts);
}
/****************************************************************************
* Name: hrtimer_reprogram
*
+1 -1
View File
@@ -92,7 +92,7 @@ int hrtimer_start(FAR hrtimer_t *hrtimer, hrtimer_entry_t func,
}
else
{
hrtimer->expired = hrtimer_gettime() + expired;
hrtimer->expired = clock_systime_nsec() + expired;
}
/* Ensure expiration time does not overflow */
+1 -1
View File
@@ -135,7 +135,7 @@ void nxsched_process_timer(void)
HRTIMER_MODE_REL);
}
hrtimer_process(hrtimer_gettime());
hrtimer_process(clock_systime_nsec());
#else
/* Fallback: process one scheduler tick */