mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: John <me@privacy.net>
Cc: linux-kernel@vger.kernel.org, tglx@timesys.com, mingo@elte.hu,
	johnstul@us.ibm.com
Subject: Re: Incorrect behavior of timer_settime() for absolute dates in the past
Date: Mon, 27 Nov 2006 18:09:45 -0800	[thread overview]
Message-ID: <20061127180945.15b37668.akpm@osdl.org> (raw)
In-Reply-To: <456AF6F5.7050201@privacy.net>

On Mon, 27 Nov 2006 15:32:21 +0100
John <me@privacy.net> wrote:

> John wrote:
> 
> > I'm playing with the POSIX timers API. My platform is x86 running Linux 
> > 2.6.18.1 patched with the high-resolution timer subsystem.
> > 
> > http://www.tglx.de/hrtimers.html
> > 
> > I'm seeing unexpected behavior from timer_settime().
> > 
> > int timer_settime(timer_t timerid, int flags,
> >   const struct itimerspec *value, struct itimerspec *ovalue);
> > 
> > timer_settime() is used to arm a timer. If the TIMER_ABSTIME flag is 
> > set, then the timer should fire when the appropriate clock reaches the 
> > date specified by value. If that date is in the past, the timer should 
> > fire immediately.
> > 
> > The Open Group Base Specifications Issue 6 states:
> > http://www.opengroup.org/onlinepubs/009695399/functions/timer_getoverrun.html 
> > 
> > 
> > "If the flag TIMER_ABSTIME is set in the argument flags, timer_settime() 
> > shall behave as if the time until next expiration is set to be equal to 
> > the difference between the absolute time specified by the it_value 
> > member of value and the current value of the clock associated with 
> > timerid. That is, the timer shall expire when the clock reaches the 
> > value specified by the it_value member of value. If the specified time 
> > has already passed, the function shall succeed and the expiration 
> > notification shall be made."
> > 
> > In my tests, when timer_settime() is called with an expiration date in 
> > the past, the timer still takes some time to fire.
> > 
> > Here's a run-down of the code provided as an attachment:
> > 
> > I switch to a SCHED_RR scheduling policy. In other words, whenever my 
> > process wants the CPU, it gets it. (No other SCHED_RR or SCHED_FIFO 
> > processes on the system.) I mask the signal that will be delivered on 
> > timer expiration. I then arm a timer with an expiration date in the 
> > past, check whether the signal is pending, and block waiting for the 
> > signal. I then print how long I've had to wait.
> > 
> > # ./a.out
> > RESOLUTION=1 ns
> > NOW=969.735545919
> > SLEEPING 1 SECOND...
> > NOW=970.735581398
> > NOW=970.735613525
> > NOW=970.735749017
> > nsdiff=135492 ns i.e. 135.5 µs
> > 
> > Any ideas?
> 
> Is there a better forum to discuss this matter?
> 

It hasn't been forgotten about.

This problem, plus the dynticks-makes-us-disable-the-TSC problem, plus
dynticks-breaks-teunis@wintersgift.com's-synaptics driver are all (IMO)
blocking a merge.


  reply	other threads:[~2006-11-28  2:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-17  9:11 John
2006-11-27 14:32 ` John
2006-11-28  2:09   ` Andrew Morton [this message]
2006-11-30 13:26 ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061127180945.15b37668.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@privacy.net \
    --cc=mingo@elte.hu \
    --cc=tglx@timesys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®