Hi Sanjay, I can figure out one problem in your module, there can be some more, but the thing which I noted is that, you have defined the timer variable of struct_timer type in init_module as local variable. There can be two cases: 1. If you define the timer as local variable, you need to put your process to sleep using any of the sleeping functions (interruptible_sleep_on() etc), just after putting the timer on kernel queue (I mean after add_timer() function). We need to do this so that the control from init-module does not go out and the local variable of that function (including the timer variable), stays on stack of that function when the timer function is executed, as when the timer will expire kernel will refer to the timer registered by you. In case you do not put your processs to sleep, timer variable will be washed away from stack and when kernel will refer it at timer expiration time, it will panic and crash. 2. Second case can be that you define the timer as global variable (outside init_module() function). In this case you need not to put your process to sleep, but in this case you need to take care of clearing the memory used by timer variable after that has been expired. I hope it was not much confusing. Regards, Gaurav. -----Original Message----- From: kernelnewbies-bounce@xxxxxxxxxxxx [mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Sanjay Kumar Sent: Friday, September 03, 2004 8:08 PM To: Kernel Newbies Subject: problem in writing a dynamic timer Hi All I want to write a small kernel module. The module will create a dynamic timer and invoke a specified function after a fixed time interval(5 sec in my case). The code for the sample module is as follows: ===========================sample code======================================= #include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/timer.h> //invoke this function after 5 seconds void call_func(unsigned long x) { printk("called from a dynamic timer\n"); //do some processing here ....... ....... } //add a timer int init_module(void) { struct timer_list timer; init_timer(&timer); timer.expires=jiffies + 5*HZ; timer.function= & call_func; add_timer(&timer); printk("this is timer_module\n"); return 0; } void cleanup_module(void) { printk("goodbye\n"); } MODULE_LICENSE("GPL"); MODULE_AUTHOR("sanjay"); MODULE_DESCRIPTION("A TEST MODULE TO CREATE A DYNAMIC TIMER") =============================end code============================================ the makefile for module reads: obj-m += timer_module.o default: make -C /lib/modules/`uname -r`/build/ SUBDIRS=$(PWD) module ======================================================================== ========= The module compiles fine. But whenever i try to insert the module, the kernel crashes giving a stack trace and following warning: <0>Kernel panic: fatal exception in interrupt handler -not syncing. kindly indicate the mistake I am making. I think the timer is deactivated after one invocation, so there is no need to del_timer_sync in this case Thanks and Regards Sanjay Kumar -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/