mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 04:19:37 +08:00
sched/clock: Improve clock implementation with sched ticks functions
Replace direct usage of g_system_ticks with clock_increase_sched_ticks() and clock_get_sched_ticks() Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
This commit is contained in:
committed by
Xiang Xiao
parent
54adf5979c
commit
1a22f4bf28
@@ -376,11 +376,7 @@ void clock_resynchronize(FAR struct timespec *rtc_diff)
|
|||||||
clock_t diff_ticks = SEC2TICK(rtc_diff->tv_sec) +
|
clock_t diff_ticks = SEC2TICK(rtc_diff->tv_sec) +
|
||||||
NSEC2TICK(rtc_diff->tv_nsec);
|
NSEC2TICK(rtc_diff->tv_nsec);
|
||||||
|
|
||||||
#ifdef CONFIG_SYSTEM_TIME64
|
clock_increase_sched_ticks(diff_ticks);
|
||||||
atomic64_fetch_add((FAR atomic64_t *)&g_system_ticks, diff_ticks);
|
|
||||||
#else
|
|
||||||
atomic_fetch_add((FAR atomic_t *)&g_system_ticks, diff_ticks);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -88,31 +88,7 @@ clock_t clock_systime_ticks(void)
|
|||||||
|
|
||||||
up_timer_gettick(&ticks);
|
up_timer_gettick(&ticks);
|
||||||
return ticks;
|
return ticks;
|
||||||
#elif defined(CONFIG_SYSTEM_TIME64)
|
|
||||||
clock_t sample;
|
|
||||||
clock_t verify;
|
|
||||||
|
|
||||||
/* 64-bit accesses are not atomic on most architectures. The following
|
|
||||||
* loop samples the 64-bit timer twice and loops in the rare event that
|
|
||||||
* there was 32-bit rollover between samples.
|
|
||||||
*
|
|
||||||
* If there is no 32-bit rollover, then:
|
|
||||||
*
|
|
||||||
* - The MS 32-bits of each sample will be the same, and
|
|
||||||
* - The LS 32-bits of the second sample will be greater than or equal
|
|
||||||
* to the LS 32-bits for the first sample.
|
|
||||||
*/
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
verify = g_system_ticks;
|
|
||||||
sample = g_system_ticks;
|
|
||||||
}
|
|
||||||
while ((sample & TIMER_MASK32) < (verify & TIMER_MASK32) ||
|
|
||||||
(sample & ~TIMER_MASK32) != (verify & ~TIMER_MASK32));
|
|
||||||
|
|
||||||
return sample;
|
|
||||||
#else
|
#else
|
||||||
return g_system_ticks;
|
return clock_get_sched_ticks();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,6 @@ void clock_systime_timespec(FAR struct timespec *ts)
|
|||||||
defined(CONFIG_SCHED_TICKLESS)
|
defined(CONFIG_SCHED_TICKLESS)
|
||||||
up_timer_gettime(ts);
|
up_timer_gettime(ts);
|
||||||
#else
|
#else
|
||||||
clock_ticks2time(ts, g_system_ticks);
|
clock_ticks2time(ts, clock_get_sched_ticks());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user