Skip to content

Commit

Permalink
time: sleep uses apic_timer_sleep
Browse files Browse the repository at this point in the history
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 <ahmeddan amazon c;0m >
  • Loading branch information
82marbag authored and wipawel committed Nov 15, 2020
1 parent d9731ff commit 7bba376
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion include/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@
#ifndef KTF_TIME_H
#define KTF_TIME_H

#include <apic.h>
#include <drivers/pit.h>
#include <ktf.h>

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

0 comments on commit 7bba376

Please sign in to comment.