The tasklet is the bottom half. Thus, in the top half, which is your hardirq handler routine, the last thing you should do before returning is "schedule" your tasklet to execute:
void tasklet_schedule(struct tasklet_struct *t);
Simply pass the pointer to your (initialized) tasklet structure to the tasklet_schedule() API; the kernel will handle the rest. What does the kernel do? It schedules this tasklet to execute; practically speaking, your tasklet's function code is guaranteed to run before control returns to the task that was interrupted in the first place (be it a user or kernel thread). More details can be found in the Understanding how the kernel runs softirqs section.
Regarding the tasklet, there are a few things you need to be clear about:
- The tasklet executes its code in an interrupt (atomic) context; it's actually a softirq context. So, remember, all the restrictions that apply to top halves apply here too! (Check...