struct work_struct{unsigned long pending;/* 这个工作正在等待处理吗?*/struct list_head entry;/* 连接所有工作的链表 */void(*func)(void*);/* 要执行的函数 */void*data;/* 传递给函数的参数 */void*wq_data;/* 内部使用 */struct timer_list timer;/* 延迟的工作队列所用到的定时器 */}; 这...
work_struct的数据结构如下,暂时我们还无法关注其原理,只关注如何去开启一个work #include<linux/include/workqueue.h>typedefvoid(*work_func_t)(structwork_struct *work);structwork_struct{atomic_long_tdata;structlist_headentry;work_func_tfunc;#ifdefCONFIG_LOCKDEPstructlockdep_maplockdep_map;#endif}; 通...
TP中断的处理,一般有种固定模式,两种实现方法,采用work_struct和work_struct workqueue_struct混合都可以处理。 (1)work_struct 定义报点函数 static struct work_struct msg21xx_wq; 1. static int touch_event_handler(void *unused) 1. probe中初始化 INIT_WORK( &msg21xx_wq, touch_event_handler ); 注...
static struct work_struct test_work; static struct delayed_work test_delayed_work; static void test_func(struct work_struct *work) { printk("%s, %d, %ld\n", __func__, __LINE__, jiffies); } static void test_delayed_func(struct work_struct *work) { printk("%s, %d, %ld\n", __...
struct work_struct{atomic_long_t data;//低比特存放状态位,高比特存放worker_pool的ID或者pool_workqueue的指针struct list_head entry;//用于添加到其他队列上work_func_t func;//工作任务的处理函数,在内核线程中回调#ifdefCONFIG_LOCKDEPstruct lockdep_map lockdep_map;#endif}; ...
工作者(struct worker) structworker {/*on idle list while idle, on busy hash table while busy*/union {structlist_head entry;/*L: while idle*/structhlist_node hentry;/*L: while busy*/};structwork_struct *current_work;/*L: work being processed*/work_func_t current_func;/*L: current...
schedule_work(struct work_struct *work) schedule_work_on(int cpu, struct work_struct *work) 一个work可以被调度到系统的任意一个CPU,也可以被调度在指定的CPU,这就是以上两个API的区别。 取消一个work_struct cancel_work(struct work_struct *work); cancel_work_sync(struct work_struct *work); 取...
struct work_struct用来描述work,初始化一个work并添加到工作队列后,将会将其传递到合适的内核线程来进行处理,它是用于调度的最小单位。 关键字段描述如下: struct work_struct { atomic_long_t data; //低比特存放状态位,高比特存放worker_pool的ID或者pool_workqueue的指针 ...
schedule_work_on(int cpu, struct work_struct *work) 一个work可以被调度到系统的任意一个CPU,也可以被调度在指定的CPU,这就是以上两个API的区别。 取消一个work_struct cancel_work(struct work_struct *work); cancel_work_sync(struct work_struct *work); ...
创建工作队列:使用宏DECLARE_WORK()或INIT_WORK()来声明或初始化一个工作项(struct work_struct)。 定义工作函数:定义一个函数来执行具体的任务,该函数的参数应为指向工作项的指针。 关联工作项和工作函数:使用INIT_WORK()函数将工作项与工作函数关联起来。