If you need to start some timer and run your routine at some time later,
you'll need to use Linux timers. There are two flavors of timers in Linux,
but the old one is deprecated, you should use just the new fast timers.
This interface is defined in
<linux/timer.h>. Basically, you
struct timerlist somewhere (usually inside of some structure with
your data), which you initialize at the beginning with
Whenever you want to activate some timer, you make sure the
expires members of the structure are filled in and call
add_timer. This will add your timer to the list of pending timers and
once current time (measured in jiffies - timer interrupt ticks) will
reach or exceed
function will be called with
data. You can also use
del_timer to de-activate some
pending timer. The timer handlers are executed in bottom half context
of the timer bottom half handler. Note that some kernel subsystems,
like scsi, use their own interfaces to add and delete timers.
Once a timer expires and calls it's
function, it is deactivated, so
basically these timers are one-shot. If you need some timer to be active
again, you need to set the
expires member and call
on it again.