The HyperNews Linux KHG Discussion Pages

Idea: Use add_timer/del_timer (in kernel/sched.c)

Forum: The Linux Kernel Hackers' Guide
Re: Question How to sleep for x jiffies? (Trent Piepho)
Date: Tue, 23 Jun 1998 22:27:06 GMT
From: Amos Shapira <amos-khg@gezernet.co.il>

At least for 2.1.xx, use the *_timer function family as defined in kernel/sched.c.

The "Linux Internals" book (not quite recommanded, better than nothing from a quick glance) mentioens only these functions, but I see other functions with interesting names:

mod_timer which seems to change an existing timer in-place

detach_timer which seems to do what del_timer does (actually it's used by del_timer) without clearing the timer_list 'next' and 'prev'.

There are a few interesting comments in include/linux/timer.h which describe a few more functions.

One thing I learned from the book is that when you call add_timer, you specify the absolut time in jiffies (i.e. for one sec say 'jiffies + (1*HZ)')