Re: kernel/timer.c: next_timer_interrupt() strange/buggy(?) code (2.6.18-rc1-mm2)

From: Prakash Punnoor
Date: Tue Jul 18 2006 - 11:12:19 EST


Am Montag Juli 17 2006 20:53 schrieb Andreas Mohr:
> for (i = 0; i < 4; i++) {
> j = INDEX(i);
> do {
> if (list_empty(varray[i]->vec + j)) {
> j = (j + 1) & TVN_MASK;
> continue;
> }
> list_for_each_entry(nte, varray[i]->vec + j, entry)
> if (time_before(nte->expires, expires))
> expires = nte->expires;
> if (j < (INDEX(i)) && i < 3)
> list = varray[i + 1]->vec + (INDEX(i + 1));
> goto found;
> } while (j != (INDEX(i)));
> }
> found:

is equivalent to

for (i = 0; i < 4; i++) {
j = INDEX(i);
do {
if (!list_empty(varray[i]->vec + j)) {
list_for_each_entry(nte, varray[i]->vec + j, entry)
if (time_before(nte->expires, expires))
expires = nte->expires;
if (j < (INDEX(i)) && i < 3)
list = varray[i + 1]->vec + (INDEX(i + 1));
goto found;
}
j = (j + 1) & TVN_MASK;
} while (j != (INDEX(i)));
}
found:


But probably the code in timer.c takes account of probabilities, thus it is a
bit more obscure.

HTH,
--
(°= =°)
//\ Prakash Punnoor /\\
V_/ \_V

Attachment: pgp00000.pgp
Description: PGP signature