sched.c documentation patch

Colin Plumb (colin@nyx.net)
Tue, 2 Jun 1998 01:40:50 -0600 (MDT)


The code is neat, but could be commented a bit better.
In particular, I think the invariant relationship between
tv?.index and timer_jiffies should be made clear so no future
hacker messes it up.

I also fixed a jiffies-overflow buglet (it requires a delay
of greater than 1<<26 jiffies that spans jiffies wrapping 2^32,
which is pretty unlikely) so that it works right.

Note that delays over 2^31 jiffies don't work on 32-bit platforms, so
perhaps a more vigorous complaint in the handling for that case
is in order.

-- 
	-Colin

--- sched.c +++ sched.c Tue Jun 2 00:18:29 1998 @@ -273,6 +273,29 @@ #define NOOF_TVECS (sizeof(tvecs) / sizeof(tvecs[0])) +/* + * A timeout within TVR_SIZE jiffies of now is linked into one of the + * lists in tv1, and every jiffy one of the bins is emptied. + * Timeouts further in the future are grouped into bins of TVR_SIZE + * jiffies and stored in one of the TVN_SIZE slots in tv2. + * timeouts further than TVR_SIZE*TVN_SIZE jiffies away are stored in tv3, + * and so on. The current settings support up to 32 bits of timeout. + * Timeouts further away than that (e.g. 48 days and 13:05:04 on an + * Alpha at 1024 Hz) are forgotten about and *never* wake up. + * + * timer_jiffies keeps track of how far the timer list has been run, + * which lags behind jiffies. (jiffies are incremented in an interrupt, + * but run_timer_list is done later by the scheduler.) + * + * The following invariants are maintained by run_timer_list: + * tv1.index == timer_jiffies & TVR_MASK + * tv2.index == (timer_jiffies >> TVR_BITS) & TVN_MASK + * tv3.index == (timer_jiffies >> TVR_BITS + TVN_BITS) & TVN_MASK + * tv3.index == (timer_jiffies >> TVR_BITS + 2*TVN_BITS) & TVN_MASK + * etc. + * thus, the "index" values are not strictly necessary. + */ + static unsigned long timer_jiffies = 0; static inline void insert_timer(struct timer_list *timer, @@ -304,7 +327,7 @@ } else if (idx < 1 << (TVR_BITS + 3 * TVN_BITS)) { int i = (expires >> (TVR_BITS + 2 * TVN_BITS)) & TVN_MASK; insert_timer(timer, tv4.vec, i); - } else if (expires < timer_jiffies) { + } else if ((long)idx < 0) { /* can happen if you add a timer with expires == jiffies, * or you set a timer to go off in the past */

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu