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(); ...
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", __...
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}; 通过...
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{ ...
worker_pool:worker池(内核线程池),是一个共享资源池,提供不同的worker来对work item进行处理; pool_workqueue:充当桥梁纽带的作用,用于连接workqueue和worker_pool,建立链接关系; 下边看看细节吧: 2.2 work struct work_struct用来描述work,初始化一个work并添加到工作队列后,将会将其传递到合适的内核线程来进行处理...
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) ...
使用work_struct的两种方式: 1. 动态初始化一个工作队列 printk("%s enter start \n",__func__); struct work_struct mywork;//定义一个工作队列 INIT_WORK(&mywork,mywork_func);//初始化工作队列 mywork_func 为要加入队列的处理函数 schedule_work(&mywork);//工作调度 让mywork_func加入队列排队 ...
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; }...
C# struct tutorial shows how to work with struct types in C#. A structure is a value type defined with the struct keyword.