struct timer_list {
struct list_head entry;
unsigned long expires;
void (*function)(unsigned long);
unsigned long data;
struct tvec_t_base_s *base;
#ifdef CONFIG_TIMER_STATS
void *start_site;
char start_comm[16];
int start_pid;
#endif
};
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/timer.h>
MODULE_LICENSE("Dual BSD/GPL");
struct timer_list timer_test;
void print_message(unsigned long parameter)
{
printk ("time over and the parameter is %lu\n", parameter);
}
static int time_init (void)
{
init_timer (&timer_test);
timer_test.expires = jiffies + 3*HZ;
timer_test.data = 888;
timer_test.function = print_message;
add_timer(&timer_test);
return 0;
}
static void time_exit (void)
{
del_timer(&timer_test);
}
obj-m := timer.o
all:
@make -C /lib/modules/`uname -r`/build M=`pwd` modules
[ 9702.790529] time over and the parameter is 888
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |