Timer function

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

 



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.
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.
 
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

[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