Messages in this thread |  | | Date | Thu, 31 Oct 1996 19:31:57 +0100 (MET) | From | Ingo Molnar <> | Subject | sys_getitimer() question |
| |
from kernel/itimer.c:sys_getitimer():
static int _getitimer(int which, struct itimerval *value) { register unsigned long val, interval;
switch (which) { case ITIMER_REAL: interval = current->it_real_incr; ---> val = 0; ---> if (del_timer(¤t->real_timer)) { ---> unsigned long now = jiffies; ---> val = current->real_timer.expires; ---> add_timer(¤t->real_timer); ---> /* look out for negative/zero itimer.. */ ---> if (val <= now) ---> val = now+1; ---> val -= now; ---> }
Why is the timer deleted and added when we are querying the value only? Or is there some usage pattern performance reason? Why not the following code:
cli(); if (current->real_timer->next) { val = current->real_timer.expires-jiffies;
/* look out for negative/zero itimer.. */ if ( (signed)val <= 0) val = 1; } else val = 0; sti();
Since add_timer() involves a linear search in the chained list of kernel timers, the overhead is much higher in the current implementation? as far as i'm aware, getitimer() doesnt change the state of the process, so this deletition/addition of the timer looks unnecessary to me.
-- mingo
|  |