dynamic timers

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

 



Hi,
I am writing a module that runs a dynamic timer.In the init function i defined a timer and given 'expires' as jiffies+3000 when i insert the module into the kernel the system is hanging and mouse is also hanging.
the code is as follows.

#ifndef __KERNEL__
    #define __KERNEL__
#endif

#ifndef MODULE
    #define MODULE
#endif

#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/timer.h>
#include <linux/jiffies.h>

MODULE_AUTHOR("RAJA");
MODULE_DESCRIPTION("TIMER_1");
MODULE_LICENSE("GPL");

static int __init init_timer1(void);
static void __exit exit_timer1(void);

void timer_func(unsigned long data)
{
    printk("Hello! Timer Has Expired\n");
}

static int __init init_timer1()
{
    printk("Entered Into Init Function\n");
    struct timer_list my_timer;
    init_timer(&my_timer);
    my_timer.expires = (jiffies + 3000);
    my_timer.data = 0;
    my_timer.function = timer_func;
    add_timer(&my_timer);
    return 0;
}

static void __exit exit_timer1()
{
    printk("Entered Into Exit Function\n");
}

module_init(init_timer1);
module_exit(exit_timer1);

will you please help me what is wrong with it?


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