????1. Tasklet???????
????????????????????ж?????linux?????????????tasklet??????????????????ж??pending???λ?32λ??????????????????????ж??????????????????????????????ж??????????????ж???????????????????????????????????????????????ɡ????????????tasklet?????????????????
??????????д???????£??????????????????????????д???????????????????????????е?????????????????????????????????????????????????????????????????????????Tasklet????????tasklet????????tasklet?????????????tasklet??????????CPU???????У???????tasklet????????CPU???????У?????????????????????
??????????????
????struct tasklet_struct
????{
????struct tasklet_struct *next;
????unsigned long state;
????atomic_t count;
????void (*func)(unsigned long);
????unsigned long data;
????};
??????????tasklet
???????tasklet??????????????????tasklet_struct???壬??????tasklet_schedule????????tasklet??????г??????func??????
void __tasklet_schedule(struct tasklet_struct *t)
{
unsigned long flags;local_irq_save(flags);
t->next = NULL;
*__get_cpu_var(tasklet_vec).tail = t;
__get_cpu_var(tasklet_vec).tail = &(t->next);
raise_softirq_irqoff(TASKLET_SOFTIRQ);
local_irq_restore(flags);
}
EXPORT_SYMBOL(__tasklet_schedule);
void __tasklet_hi_schedule(struct tasklet_struct *t)
{
unsigned long flags;
local_irq_save(flags);
t->next = NULL;
*__get_cpu_var(tasklet_hi_vec).tail = t;
__get_cpu_var(tasklet_hi_vec).tail = &(t->next);
raise_softirq_irqoff(HI_SOFTIRQ);
local_irq_restore(flags);
}
EXPORT_SYMBOL(__tasklet_hi_schedule);
????Tasklet??й???
????Tasklet_action?????ж?TASKLET_SOFTIRQ????????????У?????tasklet_vec?????а?tasklet_struct???嶼???????????????С????t->count???????0????????tasklet??????????disable??????????tasklet???????·???tasklet_vec??????????μ???TASKLET_SOFTIRQ???ж???????enable???tasklet????????????????
static void tasklet_action(struct softirq_action *a)
{
struct tasklet_struct *list;local_irq_disable();
list = __get_cpu_var(tasklet_vec).head;
__get_cpu_var(tasklet_vec).head = NULL;
__get_cpu_var(tasklet_vec).tail = &__get_cpu_var(tasklet_vec).head;
local_irq_enable();
while (list)
{
struct tasklet_struct *t = list;
list = list->next;
if (tasklet_trylock(t))
{
if (!atomic_read(&t->count))
{
if (!test_and_clear_bit(TASKLET_STATE_SCHED?? &t->state))
BUG();
t->func(t->data);
tasklet_unlock(t);
continue;
}
tasklet_unlock(t);
}
local_irq_disable();
t->next = NULL;
*__get_cpu_var(tasklet_vec).tail = t;
__get_cpu_var(tasklet_vec).tail = &(t->next);
__raise_softirq_irqoff(TASKLET_SOFTIRQ);
local_irq_enable();
}
}
????2. Linux????????
????????????????tasklet?????????tasklet????????????????????л??????????????????tasklet??????????????tasklet?е????????к???????????粻?????????????????????ù??????л???????????????????????????е???????????????????????????????е????????tasklet?????ù??????е??????????????????????????С?
????????????
??????????????????workqueue_struct??cpu_workqueue_struct???????????????????????????????????????workqueue_struct?????????????CPU????????cpu_workqueue_struct??????塣
struct cpu_workqueue_struct
{
spinlock_t lock;
struct list_head worklist;
wait_queue_head_t more_work;
struct work_struct *current_work;
struct workqueue_struct *wq;
struct task_struct *thread;
int run_depth;        /* Detect run_workqueue() recursion depth */
} ____cacheline_aligned;
/*
* The externally visible workqueue abstraction is an array of
* per-CPU workqueues:
*/
struct workqueue_struct
{
struct cpu_workqueue_struct *cpu_wq;
struct list_head list;
const char *name;
int singlethread;
int freezeable;        /* Freeze threads during suspend */
int rt;
#ifdef CONFIG_LOCKDEP
struct lockdep_map lockdep_map;
#endif
};
????Work_struct???????????????????
????struct work_struct
????{
????atomic_long_t data;
????#define WORK_STRUCT_PENDING 0        /* T if work item pending execution */
????#define WORK_STRUCT_FLAG_MASK (3UL)
????#define WORK_STRUCT_WQ_DATA_MASK (~WORK_STRUCT_FLAG_MASK)
????struct list_head entry;
????work_func_t func;
????#ifdef CONFIG_LOCKDEP
????struct lockdep_map lockdep_map;
????#endif
????};
?????????????????????????????

?????????????????????????????????????о????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????1. Workqueque?????????????????event/0??????????
????2. Work_queue????????????????е?
????3. Event/0????????δ?????????????????