[CODE]#include<linux/init.h#include<linux/sched.h#include<linux/module.h#include<linux/jiffies.h#include<asm/io.h#include<linux/timer.h#include<linux/wait.hMODULE_LICENSE("GPL");static DECLARE_WAIT_QUEUE_HEAD(wq);static int flag = 0;struct timer_list my_timer;void timer_test(unsigned long data){ printk("this is a testn"); flag = 1; wake_up_interruptible(&wq);}static int __init hello_init(void){ init_timer(&my_timer); my_timer.expires = jiffies + 5000; my_timer.data = 0; my_timer.function = timer_test; add_timer(&my_timer); wait_event_interruptible(wq, flag != 0); flag = 0; return 0;}static void __exit hello_exit(void){ del_timer(&my_timer); printk(KERN_ALERT "Goodbyen");}module_init(hello_init);module_exit(hello_exit);[/CODE]
高手进阶Linux系统中内核定时器的应用
高手进阶Linux系统中内核定时器的应用,高手进阶 Linux系统中内核定时器的应用