user a read barrier instead of a normal barrier to serialize calls of rdtsc
This commit is contained in:
parent
6462e2b0fd
commit
ae1216f757
3 changed files with 8 additions and 7 deletions
|
@ -589,10 +589,10 @@ int apic_calibration(void)
|
|||
lapic_write(APIC_ICR, 0xFFFFFFFFUL);
|
||||
|
||||
/* wait 3 time slices to determine a ICR */
|
||||
mb();
|
||||
rmb();
|
||||
start = rdtsc();
|
||||
do {
|
||||
mb();
|
||||
rmb();
|
||||
end = rdtsc();
|
||||
ticks = end > start ? end - start : start - end;
|
||||
} while(ticks*TIMER_FREQ < 3*RC_REFCLOCKMHZ*1000000UL);
|
||||
|
|
|
@ -149,12 +149,12 @@ uint32_t detect_cpu_frequency(void)
|
|||
while((ticks = get_clock_tick()) - old == 0)
|
||||
HALT;
|
||||
|
||||
mb();
|
||||
rmb();
|
||||
start = rdtsc();
|
||||
/* wait a second to determine the frequency */
|
||||
while(get_clock_tick() - ticks < TIMER_FREQ)
|
||||
HALT;
|
||||
mb();
|
||||
rmb();
|
||||
end = rdtsc();
|
||||
|
||||
diff = end > start ? end - start : start - end;
|
||||
|
|
|
@ -50,8 +50,8 @@ uint64_t get_clock_tick(void)
|
|||
void start_tickless(void)
|
||||
{
|
||||
use_tickless = 1;
|
||||
rmb();
|
||||
last_rdtsc = rdtsc();
|
||||
mb();
|
||||
}
|
||||
|
||||
void end_tickless(void)
|
||||
|
@ -71,11 +71,11 @@ void check_ticks(void)
|
|||
{
|
||||
uint64_t curr_rdtsc = rdtsc();
|
||||
|
||||
mb();
|
||||
rmb();
|
||||
if (curr_rdtsc - last_rdtsc > 1000000ULL*(uint64_t)get_cpu_frequency() / (uint64_t)TIMER_FREQ) {
|
||||
timer_ticks++;
|
||||
last_rdtsc = curr_rdtsc;
|
||||
mb();
|
||||
rmb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,7 @@ static void timer_handler(struct state *s)
|
|||
vga_puts("One second has passed\n");
|
||||
}*/
|
||||
|
||||
kputs("A");
|
||||
/* Dump load every minute */
|
||||
//if (timer_ticks % (TIMER_FREQ*60) == 0)
|
||||
// dump_load();
|
||||
|
|
Loading…
Add table
Reference in a new issue