From 7bba376f2c30ba54e78fcb448ad9fc3855e81ef1 Mon Sep 17 00:00:00 2001 From: 82marbag <69267416+82marbag@users.noreply.github.com> Date: Tue, 10 Nov 2020 13:41:56 -0500 Subject: [PATCH] time: sleep uses apic_timer_sleep sleep() prioritizes the APIC timer over the PIT as long as it's available, falling back to the PIT otherwise. Signed-off-by: Daniele Ahmed --- include/time.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/time.h b/include/time.h index a5763c71..dc5b8020 100644 --- a/include/time.h +++ b/include/time.h @@ -25,11 +25,19 @@ #ifndef KTF_TIME_H #define KTF_TIME_H +#include #include #include typedef uint64_t time_t; -static inline void sleep(time_t ms) { pit_sleep(ms); } +static inline void sleep(time_t ms) { + if (is_apic_timer_enabled()) { + apic_timer_sleep(ms); + } + else { + pit_sleep(ms); + } +} #endif