On Thu, Mar 19, 2009 at 4:37 PM, Nelson Castillo <[email protected]>wrote:

> On Thu, Mar 19, 2009 at 5:24 AM, Saransh Mittal <[email protected]>
> wrote:
> (cut)
> > /* Inside init_module */
> > init_timer ( &TimerFunctionTimer );
> > TimerFunctionTimer.expires = (jiffies + HZ);
> > TimerFunctionTimer.function = timerFunction;
> > add_timer( &TimerFunctionTimer );
>
>
> You could also do something like this:
>
> static void my_timer_f(unsigned long data) {
> }
>
> static struct timer_list my_timer = TIMER_INITIALIZER(my_timer_f, 0, 0);
>
>  /* Schedule timer. */
>  mod_timer(&my_timer, jiffies + HZ);
>

I have tried this, and it is working as expected on 2.6.24 under UML.:

#include <linux/module.h>
#include <linux/kernel.h>

struct timer_list TimerFunctionTimer;
void timerFunction(unsigned long arg)
{
    printk("\nInside timer function\n");
}

int init_module(void)
{
    init_timer ( &TimerFunctionTimer );
    TimerFunctionTimer.expires = (jiffies + HZ);
    TimerFunctionTimer.function = timerFunction;
    add_timer( &TimerFunctionTimer );
    return 0;
}

void cleanup_module(void)
{
   printk(KERN_ALERT "Goodbye world 1.\n");
}

Crash could be in the Timer handler function 'timerFunction'.

~
Chetan Nanda


>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to [email protected]
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

Reply via email to