timer problem

Daniel Baluta daniel.baluta at gmail.com
Wed Jul 6 16:48:31 EDT 2011


Hello Prashant,

> struct timer_list tim;
>
> void timfunc(unsigned long data)
> {
[..]
>        schedule_timeout(10 * HZ);
[..]
> }
>
> static int __init init_testmod(void)
> {
>        init_timer(&tim);
>        tim.expires = jiffies + HZ*5;
>        tim.data = 1000;
>        tim.function = timfunc;
>        add_timer(&tim);
>        return 0;
> }

You can find here ([1]) a good source for documenting
on kernel timers API.

Basically, the kernel has a list with registered timers and
runs the associated handlers when timeout expires.

Looking at your code, you've initialized the timer but you didn't
added it to kernel timers list.

You can find here a simple example of how to setup a timer ([2]).

Please read this [3], and figure out why even after you'll correctly
setup the timer, your timer handler will cause you trouble.

thanks,
Daniel.


[1] http://www.ibm.com/developerworks/linux/library/l-timers-list/index.html
[2] http://lxr.linux.no/linux+v2.6.39/arch/blackfin/kernel/nmi.c#L176
[3] http://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/c557.html



More information about the Kernelnewbies mailing list