On 2009-03-19, Saransh Mittal <saransh.m@xxxxxxxxx> wrote: > --0016e652ff9a6c362804657635ef > Content-Type: text/plain; charset=ISO-8859-1 > Content-Transfer-Encoding: 7bit > > Hey guys, > I m trying to schedule a Kernel Timer such that a > function I need runs when the timer expires. But with > the current way I m doing it, the system always > crashes. > > Heres what I have: > > ....... > ....... > > /* Function Prototype */ > void timerFunction( unsigned long ); > > ....... > ....... > > /* Global Variables */ > struct timer_list TimerFunctionTimer; > > ....... > ....... > > /* Inside init_module */ > init_timer ( &TimerFunctionTimer ); > TimerFunctionTimer.expires = (jiffies + HZ); > TimerFunctionTimer.function = timerFunction; > add_timer( &TimerFunctionTimer ); Initialize timer before you call init_timer() function. Change the code like this: TimerFunctionTimer.function = timerFunction; init_timer ( &TimerFunctionTimer ); You do not need add_timer(). In you timer process function, set expire value and call mod_timer(). > > ...... > ...... > > Am I doing something wrong here ? Any help would be > greatly appreciated. Thank you. > > --0016e652ff9a6c362804657635ef > Content-Type: text/html; charset=ISO-8859-1 > Content-Transfer-Encoding: 7bit > ><pre>Hey guys,<br>I m trying to schedule a Kernel Timer such that a<br>function I need runs when the timer expires. But with<br>the current way I m doing it, the system always<br>crashes. <br><br>Heres what I have:<br><br> > .......<br>.......<br><br>/* Function Prototype */<br>void timerFunction( unsigned long );<br><br>.......<br>.......<br><br>/* Global Variables */<br>struct timer_list TimerFunctionTimer;<br><br>.......<br>.......<br><br> > /* Inside init_module */<br>init_timer ( &TimerFunctionTimer );<br>TimerFunctionTimer.expires = (jiffies + HZ);<br>TimerFunctionTimer.function = timerFunction;<br>add_timer( &TimerFunctionTimer );<br><br>......<br> > ......<br><br>Am I doing something wrong here ? Any help would be<br>greatly appreciated. Thank you.</pre> > > --0016e652ff9a6c362804657635ef-- > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx > Please read the FAQ at http://kernelnewbies.org/FAQ > > -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ