tasklet and workqueue(from linux kernel development )
2011-09-13 14:42
411 查看
difference between those two mechanism :
tasklet is delayed for short time ,and it cannot sleep !
workqueue can be delayed for long time ,and it can sleep in the interrupt time !
workqueue is treated as kernel thread !
tasklet is made on the top of softirq!
they all used in interrupt handler (bottom half )!
what is the softirq ?
it is a mechanism looksmart like software interrupt !
detail about workqueue:it deferred work into kernel thread! so code of this bottom half can run in the process context ! And workqueue has all the benefit of process !it is scheduled and can be sleep !
use workqueue is going to create a new kernel thread !
workqueue is usually an interface to create a kernel thread to handle workqueue elsewhere!
kernel thread is called worker thread !
the workqueue subsystem implement and provide a default worker thread for deferred work queue!
default worker thread (kernel thread )is named events/n,n is the processor number !
that is how much processor ,then how many work thread!we can create our own kernel thread if necessary !
default worker thread is preferred !but also our own worker thread get some benefit !
the worker thread is represented by the structure workerqueue _struct (like task_struct of process )
struct workqueue_struct {
struct cpu_workqueue_struct cpu_wq[NR_CPUS];/////////////////////////////////////////////////
struct list_head list;
const char *name;
int singlethread;
int freezeable;
int rt;
};
struct cpu_workqueue _struct is per -processor ! workqueue of each processor have one such structure !
struct cpu_workqueue_struct {
spinlock_t lock; /* lock protecting this structure */
struct list_head worklist; /* list of work */
wait_queue_head_t more_work;
struct work_struct *current_struct;
struct workqueue_struct *wq; /* associated workqueue_struct */
task_t *thread; /* associated thread *//////////////////////////////////////////////////////////////
};
each processor have one worker thread !
struct work_struct {
atomic_long_t data;
struct list_head entry;
work_func_t func;
};
function associated with worker thread
those structure is strung into a link list ! one node is each structure of worker thread of each processor
tasklet is delayed for short time ,and it cannot sleep !
workqueue can be delayed for long time ,and it can sleep in the interrupt time !
workqueue is treated as kernel thread !
tasklet is made on the top of softirq!
they all used in interrupt handler (bottom half )!
what is the softirq ?
it is a mechanism looksmart like software interrupt !
detail about workqueue:it deferred work into kernel thread! so code of this bottom half can run in the process context ! And workqueue has all the benefit of process !it is scheduled and can be sleep !
use workqueue is going to create a new kernel thread !
workqueue is usually an interface to create a kernel thread to handle workqueue elsewhere!
kernel thread is called worker thread !
the workqueue subsystem implement and provide a default worker thread for deferred work queue!
default worker thread (kernel thread )is named events/n,n is the processor number !
that is how much processor ,then how many work thread!we can create our own kernel thread if necessary !
default worker thread is preferred !but also our own worker thread get some benefit !
the worker thread is represented by the structure workerqueue _struct (like task_struct of process )
struct workqueue_struct {
struct cpu_workqueue_struct cpu_wq[NR_CPUS];/////////////////////////////////////////////////
struct list_head list;
const char *name;
int singlethread;
int freezeable;
int rt;
};
struct cpu_workqueue _struct is per -processor ! workqueue of each processor have one such structure !
struct cpu_workqueue_struct {
spinlock_t lock; /* lock protecting this structure */
struct list_head worklist; /* list of work */
wait_queue_head_t more_work;
struct work_struct *current_struct;
struct workqueue_struct *wq; /* associated workqueue_struct */
task_t *thread; /* associated thread *//////////////////////////////////////////////////////////////
};
each processor have one worker thread !
struct work_struct {
atomic_long_t data;
struct list_head entry;
work_func_t func;
};
function associated with worker thread
those structure is strung into a link list ! one node is each structure of worker thread of each processor
相关文章推荐
- Linux Kernel and Driver Development Training——linux-kernel-slides
- Linux Kernel and Driver Development Training
- linux 中断处理 tasklet workqueue
- How SMP schedule work in Linux kernel? (ARM architecture)
- linux workqueue
- Linux Kernel Development 笔记(一)Linux 内核特点
- Linux-USB Gadget : Part 2: USB Gadget API for Linux (From Linux kernel 2.6.25.10)
- linux驱动之定时任务timer,队列queue,小任务tasklet机制及用法
- lpc1343 usb isp not work in linux and mac
- work queue in Linux 2.3.36
- Linux Kernel Development 笔记(二)进程
- Linux Kernel Development有关内存管理
- linux workqueue 原理解析
- Linux Kernel and Android 休眠与唤醒
- Myths, Lies, and Truths about the Linux kernel
- Linux workqueue_struct 前后版本的比较
- marvell pxa2128 uboot/linux kernel fast ethernet development documentary No.2
- Entering the kernel without a driver and getting interrupt information from APIC
- linux kernel and driver-编译安装内核
- The Proccess of Loading and Executing a Specific Program in Linux Kernel