linux-2.6.0工作队列关键数据结构

源码文件:linux-2.6.0/kernel/workqueue.c

工作队列结构体

/*
* The externally visible workqueue abstraction is an array of
* per-CPU workqueues:
*/
struct workqueue_struct {
     struct cpu_workqueue_struct cpu_wq[NR_CPUS];
};

每cpu工作队列结构体

/*
* The per-CPU workqueue.
*
* The sequence counters are for flush_scheduled_work(). It wants to wait
* until until all currently-scheduled works are completed, but it doesn't
* want to be livelocked by new, incoming ones. So it waits until
* remove_sequence is >= the insert_sequence which pertained when
* flush_scheduled_work() was called.
*/
struct cpu_workqueue_struct {

     spinlock_t lock;

     long remove_sequence;    /* Least-recently added (next to run) */
     long insert_sequence;    /* Next to add */

     struct list_head worklist;
     wait_queue_head_t more_work;
     wait_queue_head_t work_done;

     struct workqueue_struct * wq;
     task_t * thread;
     struct completion exit ;

} ____cacheline_aligned;

涉及到工作队列的主要结构体就上面的2个。2.6.0版本中,工作队列是比较好理解的。cpu_workqueue_struct结构体分布在每个CPU上,它包含一条工作链,链中的每个节点为work_struct。在创建一个work_struct时,把它插入到cpu_workqueue_struct结构体中的工作链表尾部。至于这个work_struct插入到哪个CPU上的工作链,由所在的CPU决定。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值