Re: [patch] jiffies wraparound [Re: 2.1.125 Show stopper list: Draft]

MOLNAR Ingo (mingo@chiara.csoma.elte.hu)
Sun, 18 Oct 1998 16:36:05 +0200 (CEST)


On Sun, 18 Oct 1998, Andrea Arcangeli wrote:

> Right now I just converted every tsk->timeout to tsk->use_timeout:1 and
> tsk->timeout_value [...]

i'd like to propose a (i think) cleaner interface which also does the
schedule() cleanup too. (if we change all p->timeout uses we should use a
clean and better to maintain interface instead of yet another bandaid)

old usage:

timeout = HZ/10;
...
current->timeout = jiffies + timeout;
do {
schedule();
if (whatever->flag)
break;
} while (current->timeout);
current->timeout = 0;

new implementation gets rid of the per-task timer and per-task timeout
value. This effectively puts both of them onto the stack and thus probably
improves performance even in the timeout case. And for the common
non-timeout schedule() we have a speedup too because we do not have those
2 extra (non taken) branches that look at current->timeout. The core of it
is the new schedule_timeout(&timeout) function:

timeout = HZ/10;
...
do {
schedule_timeout(&timeout);
if (whatever->flag)
break;
} while (timeout);

with the special values '0' and '-1' devoted to 'no timeout' and
'forever'. And since the timeout is delta, there are no wraparound issues.

-- mingo

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/