Find the answer to your Linux question:
Results 1 to 3 of 3
I tried to write a simple module where add_timer() was used to make the kernel call my function after a time. The two simple source files are listed (omit header ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2004
    Posts
    43

    bug: kernel timer added twice


    I tried to write a simple module where add_timer() was used to make the
    kernel call my function after a time. The two simple source files are
    listed (omit header file).

    module.c as follows:
    int init_module(void)
    {
    unsigned long timeout;
    timeout=10;
    my_timeout(timeout);
    }

    auto.c as follows:

    void my_timeout(signed long timeout)
    {
    struct timer_list timer;
    unsigned long expire;

    expire = timeout +jiffies;

    timer.expires=expire;
    timer.data=0;
    timer.function=autoprint;

    add_timer(&timer);
    }

    void *autoprint(unsigned long data)
    {
    printk(KERN_DEBUG "hello world\n");
    }

    It passed compilation, but failed in execution. After I inserted the module, it said, "bug: kernel timer added twice". However, I just use add_timer() ONCE, so I am very confused. Could anyone give me any suggestion? Thanks a lot!

  2. #2
    Just Joined!
    Join Date
    Jan 2005
    Location
    Toronto, ON, Canada
    Posts
    79
    You do not have any hook funcions that could call add_timer countiunosly (before the had expired), So only possible way you get that message is if the timer have been set for long time enough allowing you to unload and load the module between.

    I suggest you to do del/detach_timer in clean_module. And also to reboot your box toreset all timers your kernel had set up.


    afrolinux

  3. #3
    Just Joined!
    Join Date
    Nov 2004
    Posts
    43
    Quote Originally Posted by afrolinux
    You do not have any hook funcions that could call add_timer countiunosly (before the had expired), So only possible way you get that message is if the timer have been set for long time enough allowing you to unload and load the module between.

    I suggest you to do del/detach_timer in clean_module. And also to reboot your box toreset all timers your kernel had set up.


    afrolinux
    Thanks a lot. Got it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •