[okl4-developer] System hangs, bug in 8254 timer driver??
Ben Leslie
benno at ok-labs.com
Mon Sep 17 08:52:56 EST 2007
On Fri Sep 14, 2007 at 09:51:46 +0530, Kalamkar, Dhiraj D wrote:
>Hi,
>
>
>
>I am using L4 with Wombat on a 3GHz Intel Xeon processor with 1GB RAM.
>L4 and wombat boots fine and give me a shell prompt. But whenever I go
>to kernel debugger (using Ctrl +k) and try to resume back, system hangs.
>After that nothing works. Similar thing happens when I use hard disk or
>network driver.
>
>
>
>Initially I thought it is problem with some interrupt handler which is
>not restoring state correctly. But after deep debugging it turned out
>that ig_timer eats up all the CPU time keeping all other threads
>unscheduled.
>
>
>
>Here is the problem and solution:
>
>static uint64_t get_ticks(void)
>
>{
>
> uintptr_t diff, value;
>
>
>
> /* Latch the count value */
>
> outb(PIT_MCR, 0x0);
>
> delay(1);
>
> value = inb(PIT_CNT_0);
>
> delay(1);
>
> value |= inb(PIT_CNT_0) << 8;
>
>
>
> if (value <= count_from)
>
> {
>
> diff = count_from - value;
>
> }
>
> else
>
> {
>
> diff = ((1ul<<16) + count_from) - value;
>
> }
>
>
>
> return ticks + diff;
>
>}
>
>
>
>In function get_ticks(), if the value read from PIT is 0 (which happens
>when there are multiple timers already expired and processor finishes
>execution of 1 loop of timer_callback() within 1 clock cycle of PIT,
>i.e. if processor is too fast :-) ), it incorrectly calculate diff =
>64K. This causes ticks growing faster than next_timeout and ultimately
>unending while loop inside timer_callback() of ig_timer.
>
>To fix this problem I added check:
>
>if(value == 0) value = (1<<16);
>
>after reading value from PIT. And surprisingly that single statement
>solved my problem :-).
Good to hear! Thanks for contributing the solution back. We will look
at integrating the fix into our next release.
Cheers,
Ben
More information about the Developer
mailing list