Hi, find my response inline.. On 2/2/06, Adil Mujeeb <mujeeb.adil@xxxxxxxxx> wrote: > Hi, > Iam trying to set timer for two functions in a module using single > timer_list. but only the second timer function is being called, probably the > overriding the previous one. Since there is only a single timer_list variable, it will get overridden for sure on second initialisation. > Is there any way to set the timer for multiple functions using same timer > list? > or we have to use separate timer_list structure for each one. A single timer_list can hold info only for a single timer. For e.g it has a field "unsigned long expires". The moment you will try to initialise timer_list again with a new expire values, its value will be overridden and only the new expire value will be there. Its like assigning a value to a variable. Only the last value will be held by the variable So better use seperate timer_lists. Regards, Sanjay > > The sample code snippet : > > #include <linux/module.h> /* Needed by all modules */ > #include <linux/kernel.h> /* Needed for KERN_ALERT */ > #include <linux/timer.h> > #include <linux/time.h> > > struct timer_list t1; > void hello1(); > void hello2(); > extern unsigned long jiffies; > void set_timer(struct timer_list *, void (*func)(),int ); > int init_module(void) > { > printk("<1>Hello world 1.\n"); > > set_timer(&t1,hello1,3*HZ); > set_timer(&t1,hello2,6*HZ); > return 0; > } > > > void cleanup_module(void) > { > printk(KERN_ALERT "Goodbye world 1.\n"); > } > > void set_timer(struct timer_list *tl, void (*func)(),int timer){ > init_timer(tl); > tl->function = func; > tl->expires = jiffies + timer; > add_timer(tl); > } > > void hello1(){ > printk("Timer function hello1()\n"); > } > void hello2(){ > printk("Timer function hello2()\n"); > } > > Rgds, > Adil -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/