timer problem

Daniel Baluta daniel.baluta at gmail.com
Thu Jul 7 05:18:08 EDT 2011


On Wed, Jul 6, 2011 at 11:48 PM, Daniel Baluta <daniel.baluta at gmail.com> wrote:
> 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]).

Oh, so it seems you called add_timer :D, I just missed it. Then the problem
is the one pointed below (schedule_timeout called in interrupt context).

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



More information about the Kernelnewbies mailing list