Re: Kernel timers problem

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

 



Hello,

vaishali paisal wrote:

void set_timer(void)
{
static struct timer_list mytimer;
static int i=1;
struct timeval timecount;
init_timer(&mytimer);
mytimer.expires=jiffies+2*HZ;
mytimer.data=i;
mytimer.function=(void*)timer_timeout;
add_timer(&mytimer);
do_gettimeofday(&timecount);
printk(KERN_INFO "\ntimer%d started at :%ld seconds %ld microseconds",i++,timecount.tv_sec,timecount.tv_usec);
return;
}

I think you should not declare "mytimer" as a local variable, but rather as a global variable, because it is still needed after set_timer() has returned. When declared as static local variable, its remains after set_timer() has returned, that's why it works with static, but not without.


Sincerly,

Thomas
--
Thomas Petazzoni
thomas.petazzoni@xxxxxxxx

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           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