Tasklet are (together with softirqs) 2.4.x kernel's replacement to bottom halfs. They work pretty much like the old bottom halfs, but with some big advantages to SMP systems.

In the old, pre-2.2 kernel, whenever you scheduled a bottom half, it would be marked for execution later. The problem was that, no matter how many CPUs you had, only one bottom half would run at a time. It was a lot easier to implement, but it really sucked perfomance-wise.

The 2.4 kernel fixed it, adding tasklets. Tasklets are dynamically-registrable, which mean that there isn't a limit on how many of them can be scheduled. They still have a limitation of being run only by a single CPU, but, unlike bottom-halves, you can have how many tasklets running as your number of CPUs.

The code to use them is pretty simple too. Here is a excerpt

Disclaimer: Some time ago this code was causing bad freezes in my kernel. I think that it is due to another stupid thing I did, but don't sue me if it freezes your pc too. Just reboot it and have a deep breath

To schedule a tasklet like this:

void serial_bh(unsigned long data);

Just declare your tasklet:

DECLARE_TASKLET(serial_tasklet, serial_bh, 0);

Note that "serial_tasklet" is the name of a variable you will create

And then, in the irq handler, schedule it:

// code here //
tasklet_schedule(&serial_tasklet);
// more code here //

See? That's pretty easy, isn't it?

Disclaimer: I'm still learning kernel programming... the above information can be wrong... if it is, please correct me!

Log in or register to write something here or to contact authors.