linux/include/linux/timer.h 4.15 之前版本 struct timer_list { 14 /* 15 * All fields that change during normal runtime grouped to the 16 * same cacheline 17 */ 18 struct hlist_node entry; 19 unsigned long expires; 20 void (*function)(unsigned long); 21 unsigned long data; 22 u32 flags; 23 24#ifdef CONFIG_LOCKDEP 25 struct lockdep_map lockdep_map; 26#endif 27};
使用流程: struct timer_list timer_fs; timer_fs.expires = 500; //定时器定时50秒 timer_fs.data = (unsigned long)100; //不再提供data 成员变量 timer_fs.function = function;//参数类型变化 init_timer(&timer_fs); //不再提供 该初始化函数 4.15 之后版本 struct timer_list { 12 /* 13 * All fields that change during normal runtime grouped to the 14 * same cacheline 15 */ 16 struct hlist_node entry; 17 unsigned long expires; 18 void (*function)(struct timer_list *); 19 u32 flags; 20 21#ifdef CONFIG_LOCKDEP 22 struct lockdep_map lockdep_map; 23#endif 24};
使用方法;
DEFINE_TIMER(_name, _function)