diff options
Diffstat (limited to 'sys/amd64/isa/clock.c')
-rw-r--r-- | sys/amd64/isa/clock.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index e875610..9918a66 100644 --- a/sys/amd64/isa/clock.c +++ b/sys/amd64/isa/clock.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/limits.h> #include <sys/module.h> +#include <sys/sched.h> #include <sys/sysctl.h> #include <sys/cons.h> #include <sys/power.h> @@ -269,7 +270,21 @@ DELAY(int n) int getit_calls = 1; int n1; static int state = 0; +#endif + + if (tsc_freq != 0 && !tsc_is_broken) { + uint64_t start, end, now; + sched_pin(); + start = rdtsc(); + end = start + (tsc_freq * n) / 1000000; + do { + now = rdtsc(); + } while (now < end || (now > start && end < start)); + sched_unpin(); + return; + } +#ifdef DELAYDEBUG if (state == 0) { state = 1; for (n1 = 1; n1 <= 10000000; n1 *= 10) |