[okl4-developer] System hangs, bug in 8254 timer driver??

Kalamkar, Dhiraj D dhiraj.d.kalamkar at intel.com
Fri Sep 14 14:21:46 EST 2007


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 :-).

 

Thanks,

Dhiraj

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.okl4.org/pipermail/developer/attachments/20070914/546db408/attachment.htm 


More information about the Developer mailing list