INIT_DELAYED_WORK(&ofndata.x_work, ofn_x_work_func); 1. 首次调用的地方,20ms后执行: schedule_delayed_work(&ofndata.x_work, msecs_to_jiffies(20)); 1. 首次调用之后,该函数开始循环间隔40ms时间执行,即自己调用自己: static void ofn_x_work_func(struct work_struct *work) { ofn_ppg(); ...
bool cancel_work_sync(struct work_struct *work); 取消work结构体对应的func函数,一般在exit中使用 接下来,在这个链接,将会在中断里用到它们: https://www.cnblogs.com/lifexy/p/9629699.html delayed_work之相关函数 在上个链接,我们只是讲了work_struct如何使用而在内核中,除了work_struct外,还有一个结构...
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}; 通...
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", __...
schedule_work(work); 通知内核线程,在后续的时间里,系统将会自动调用work结构体对应的func函数 3. boolcancel_work_sync(structwork_struct *work); 取消work结构体对应的func函数,一般在exit中使用 接下来,在这个链接,将会在中断里用到它们:https://www.cnblogs.com/lifexy/p/9629699.html ...
structwork_structphy_queue;// PHY工作队列 structdelayed_workstate_queue;// PHY延时工作队列 atomic_tirq_disable; structmutexlock; structnet_device*attached_dev;// 网络设备 void(*adjust_link)(struct net_device *dev); }; phy_driverstructphy_driver{ ...
struct work_struct destroy_work; struct mutex s_sync_lock; int s_stack_depth; spinlock_t s_inode_list_lock ___cacheline_aligned_in_smp; struct list_head s_inodes; spinlock_t s_inode_wblist_lock; struct list_head s_inodes_wb; }...
worker_pool:worker池(内核线程池),是一个共享资源池,提供不同的worker来对work item进行处理; pool_workqueue:充当桥梁纽带的作用,用于连接workqueue和worker_pool,建立链接关系; 下边看看细节吧: 2.2 work struct work_struct用来描述work,初始化一个work并添加到工作队列后,将会将其传递到合适的内核线程来进行处理...
Linux 内核中 , 所有 进程管理 相关算法逻辑 , 都是基于task_struct结构体的 ; task_struct结构体在linux-5.6.18\include\linux\sched.h头文件中定义 , 第 629 ~ 1300 行就是struct task_struct结构体定义的代码 ; 二、task_struct 结构体代码示例 ...
struct是结构体的缩写,它是一种用户定义的复合数据类型。与数组不同,结构体中的每个数据项可以有不同的数据类型。 struct的定义通过以下语法: struct 结构体名称 { 数据类型1 变量1; 数据类型2 变量2; ... }; 在结构体定义的末尾可以添加一个分号。