lkml.org 
[lkml]   [1996]   [Oct]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectsys_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(&current->real_timer)) {
---> unsigned long now = jiffies;
---> val = current->real_timer.expires;
---> add_timer(&current->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


\
 
 \ /
  Last update: 2005-03-22 13:38    [W:0.049 / U:0.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site