Re: kernel timer problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Thu, Mar 19, 2009 at 4:37 PM, Nelson Castillo <nelsoneci@xxxxxxxxx> wrote:
On Thu, Mar 19, 2009 at 5:24 AM, Saransh Mittal <saransh.m@xxxxxxxxx> 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 ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux