X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdevices%2Ftimer.c;h=662e0c6f5645be139fde64f9f300bcd0f17d9c52;hb=48fe0532fd45f71d867b1550190689ab1196def4;hp=c8c41d55cf412948eb71a04b52c748f0c554465d;hpb=400c8c5ba0d309716ad7d347dff067ddb2f99a74;p=pintos-anon diff --git a/src/devices/timer.c b/src/devices/timer.c index c8c41d5..662e0c6 100644 --- a/src/devices/timer.c +++ b/src/devices/timer.c @@ -57,8 +57,11 @@ timer_calibrate (void) /* Approximate loops_per_tick as the largest power-of-two still less than one timer tick. */ loops_per_tick = 1u << 10; - while (!too_many_loops (loops_per_tick << 1)) - loops_per_tick <<= 1; + while (!too_many_loops (loops_per_tick << 1)) + { + loops_per_tick <<= 1; + ASSERT (loops_per_tick != 0); + } /* Refine the next 8 bits of loops_per_tick. */ high_bit = loops_per_tick; @@ -162,7 +165,7 @@ too_many_loops (unsigned loops) differently in different places the results would be difficult to predict. */ static void NO_INLINE -busy_wait (int64_t loops) +busy_wait (volatile int64_t loops) { while (loops-- > 0) continue;