# Include <Linux/module. h>
# Include <Linux/init. h>
# Include <Linux/sched. h>
# Include <Linux/Timer. h>
Struct timer_list my_timer;
Void func (unsigned long data)
{
Printk ("time out! \ N data: % lD, PID: % LD \ n ", data, current-> PID );
Mod_timer (& my_timer, jiffies + 3 * Hz );//Modify the timer time2Seconds
}
Static int _ init my_timer_init (void)
{
Init_timer (& my_timer );//Initialize Timer
My_timer.expires = jiffies + 5 * Hz ;//Set the timer time5Seconds
My_timer.function = func ;//Timer time to the function to be executed
My_timer.data = (unsigned long) 99; // funcFunction Parameters
Add_timer (& my_timer );//Register a timer
Printk ("this is my timer PID: % LD \ n", current-> PID );
Return 0;
}
Static void _ exit my_timer_exit (void)
{
Del_timer (& my_timer );//Logout Timer
Printk ("good bye \ n ");
}
Module_license ("GPL ");
Module_author ("Mike Chen ");
Module_init (my_timer_init );
Module_exit (my_timer_exit );