From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Linus Torvalds <torvalds@transmeta.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] 'select' failure or signal should not update timeout
Date: Wed, 24 Jul 2002 14:44:33 +0100 [thread overview]
Message-ID: <20020724144433.B7192@kushida.apsleyroad.org> (raw)
In-Reply-To: <m13cudnled.fsf@frodo.biederman.org>; from ebiederm@xmission.com on Sun, Jul 21, 2002 at 09:36:10AM -0600
Eric W. Biederman wrote:
> torvalds@transmeta.com (Linus Torvalds) writes:
> > A _useful_ interface would be to say "I want to sleep to at most time X"
> > or "to at least time X". Those are unambiguous things to say, and are
> > not open to interpretation.
>
> Sleeping until at most time X is only useful if the kernel can actually
> make a guarantee like that. If you are doing hard real time fine, otherwise
> that doesn't work to well.
Oh, that would definitely be useful even if it's only a "soft"
guarantee. Especially with recent HZ changes.
Typical soft real-time code looks a bit like this pseudo-code (excuse
the bugs :-):
void wait_until_time (const struct timeval * until)
{
struct timeval now, timeout;
while (1) {
gettimeofday (&now, 0);
timeout.tv_sec = until->tv_sec - now.tv_sec;
timeout.tv_usec = until->tv_usec - now.tv_usec;
if (timeout.tv_usec < 0) {
timeout.tv_usec += 1000000;
timeout.tv_sec -= 1;
}
if (timeout.tv_sec < 0)
break; /* Finished! */
timeout.tv_usec -= SCHEDULER_GRANULARITY;
if (timeout.tv_usec < 0) {
timeout.tv_usec += 1000000;
timeout.tv_sec -= 1;
}
/* Busy wait if within scheduler granularity. */
if (timeout.tv_sec > 0) {
select (0, 0, 0, &timeout);
}
}
}
Note that SCHEDULER_GRANULARITY is an architecure-specific and
OS-specific constant that has to be determined somehow.
The select() call in the above code is one that would, ideally, be "wait
until at most TIME" even if that is limited by the granularity of
scheduler timeouts. The scheduler may not be able to _guarantee_ to
schedule the process before TIME (fair enough, that's why we call it
soft real-time), but at least the tick calculations etc. in the kernel
would be rounded down, rather than up.
-- Jamie
next prev parent reply other threads:[~2002-07-24 13:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200207171430.g6HEUvY23619@aztec.santafe.edu>
2002-07-19 9:52 ` Paul Eggert
2002-07-20 0:38 ` Alan Cox
2002-07-20 5:57 ` Linus Torvalds
2002-07-21 15:36 ` Eric W. Biederman
2002-07-24 13:44 ` Jamie Lokier [this message]
2002-07-24 18:48 ` Linus Torvalds
2002-07-24 19:07 ` Chris Friesen
2002-07-24 23:30 ` Jamie Lokier
2002-07-25 6:32 ` Rusty Russell
2002-07-25 18:31 ` george anzinger
2002-07-28 5:40 ` David Schwartz
2002-07-25 16:35 ` Eric W. Biederman
2002-07-25 17:15 ` Jamie Lokier
2002-07-21 16:00 ` Christoph Rohland
2002-07-21 16:43 ` Linus Torvalds
2002-07-21 17:51 ` dean gaudet
2002-07-22 3:59 ` Edgar Toernig
2002-07-22 6:51 ` Christoph Rohland
2002-07-21 16:26 ` Ingo Molnar
2002-07-21 20:14 ` Richard Stallman
2002-07-20 3:59 dank
2002-07-21 3:34 Peter T. Breuer
2002-07-28 10:33 linux
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=20020724144433.B7192@kushida.apsleyroad.org \
--to=lk@tantalophile.demon.co.uk \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.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
Powered by JetHome