On Fri, 06 May 2005 Thomas Petazzoni wrote :
>Hello,
>
>vaishali paisal wrote:
>
> 1) Do not top post
> 2) Reply to the list, not to me
>
>>i think you are right as it works both ways - i mean if i declare it as global or static.But even if i declare it as global calling set_timer multiple times hangs the system.
>
>Please send us the code where you're calling set_timer() multiple times.
>
>Thomas
>-- Thomas Petazzoni
>thomas.petazzoni@xxxxxxxx
I am sorry about that , I will take care in future.
Following is the code:
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/init.h>
#include<linux/sched.h>
#include<linux/timer.h>
struct timer_list mytimer;
void timer_timeout(int c)
{
struct timeval timecount;
do_gettimeofday(&timecount);
printk(KERN_INFO "\ntimer%d expired at :%ld seconds %ld microseconds",c,timecount.tv_sec,timecount.tv_usec);
}
void set_timer(void)
{
static int i=1;
struct timeval timecount;
init_timer(&mytimer);
mytimer.expires=jiffies+2*HZ;
mytimer.data="">
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;
}
int time_init(void)
{
int i;
for(i=0;i<3;i++)
set_timer();
return 0;
}
void time_cleanup(void)
{
printk(KERN_INFO "\ntimer unloaded\n");
}
module_init(time_init);
module_exit(time_cleanup);
MODULE_LICENSE("GPL");
actually i want to start multiple timers simultaneously.
Regards
vaishali