From: Theodore Tso <tytso@mit.edu>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
Segher Boessenkool <segher@kernel.crashing.org>,
Dave Airlie <airlied@gmail.com>,
linux-kernel@vger.kernel.org, a.zummo@towertech.it,
jg@freedesktop.org
Subject: A better interface, perhaps: a timed signal flag
Date: Wed, 26 Jul 2006 10:45:36 -0400 [thread overview]
Message-ID: <20060726144536.GA28597@thunk.org> (raw)
In-Reply-To: <20060726002043.GA5192@localhost.localdomain>
On Tue, Jul 25, 2006 at 08:20:43PM -0400, Neil Horman wrote:
> > Yes, there are plenty of systems which don't have an RTC, or have an RTC
> > which can't generate interrupts.
> >
> Ok, for those implementations which don't have an RTC that the rtc driver can
> drive, the mmap functionality will not work, but at that point what interface
> are you left with at all for obtaining periodic time?
Well, the HPET, for one. My main problem with this interface is that
it is tied to the /dev/rtc, and the system may have any number of
timer hardware that may be more appropriate, and it shouldn't be up to
the user application to select which one.
But this does bring up an interesting coding paradigm which is used by
more than just the X server. As it turns out, there is a real-time
garbage collector[1] for Java that needs exactly the same thing, although
the resolution window is a few orders of magnitude faster than what X
needs. Fundamentally, this coding paradigm is:
while (work to do) {
do_a_bit_of_work();
if (we_have_exceeded_a_timeout_period())
break;
}
/* Clean up and let some other client/thread run */
So there are a couple of things to note about this high-level
abstracted paradigm. The application doesn't need to know _exactly_
how much time has passed, just whether or not the the appointed time
slice has expired (which might be 10ms or it might be 100us in the
case of the rt garbage collector). So calculating exactly how much
time has ellapsed is not necessary, and if there is a single-shot
event timer hardware available to the system, it might be sufficient.
So even if a VDSO implementation of gettimeofday() would be faster
than calling gettimeofday(), it still may be doing work that strictly
speaking doesn't need to happen; if the application doesn't need to
know exactly how many microseconds have gone by, but just whether or
not 150us has ellapsed, why calculate the necessary time? (Especially
if it requires using some ACPI interface...)
Secondly, it's different from a kernel-mediated secheduler timeslice
because the application needs to give up control only at certain
specifically defined stopping points (i.e., after copying a tiny
amount of live data in an incremental garbage collector design, or
after servicing a single X request, for example), and it may need to
do some cleanups. So it's often not possible to just say, well, put
it in its own thread, and let the scheduler handle it.
So maybe what we need is an interface where a particular memory
location gets incremented when a timeout has happened. It's probably
enough to say that each thread (task_struct) can have one of these
(another problem with using /dev/rtc and tieing it directly to
interrupts is that what happens if two processes want to use this
facility?), and what hardware timer source gets used is hidden from
the user application. In fact, depending on the resolution which is
specified (i.e., 100's of microseconds versus 10's of milliseconds),
different hardware might get used; we should leave that up to the
kernel.
The other thing which would be nice is if the application could
specify whether it is interested in CPU time or wall clock time for
this timeout.
If we had such an interface, then the application would look like
this:
volatile int flag = 0;
register_timout(&time_val, &flag);
while (work to do) {
do_a_bit_of_work();
if (flag)
break;
}
Finally, a note about tickless designs. Very often such applications
don't need a constantly ticking design. For example, the X server
only needs to have the memory location incremented while it is
processing events; if the laptop is idle, there's no reason to have
the RTC generating interrupts and incrementing memory locations.
Similarly, the Metronome garbage collector would only need to poll to
see if the timeout has expired while the garbage collector is running,
which is _not_ all of the time.
Yes, you could use ioctl's to start and stop the RTC interrupt
handler, but that's just ugly, and points out that maybe the interface
should not be one of programming the RTC interrupt frequency directly,
but rather one of "increment this flag after X units of
(CPU/wallclock) time, and I don't care how it is implemented at the
hardware level."
Regards,
- Ted
[1] http://www.research.ibm.com/people/d/dfb/papers/Bacon03Metronome.pdf
"The Metronome: A Simpler Approach to Garbage Collection in Real-time
Systems", by David Bacon, Perry Cheng, and V.T. Rajan, Workshop on
Java Technologies for Real-Time and Embedded Systems (Catania, Sicily,
November 2003. (See also http://www.research.ibm.com/metronome)
next prev parent reply other threads:[~2006-07-26 14:46 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-25 17:41 [PATCH] RTC: Add mmap method to rtc character driver Neil Horman
2006-07-25 17:55 ` Arjan van de Ven
2006-07-25 18:01 ` Jim Gettys
2006-07-25 18:22 ` Neil Horman
2006-07-25 18:32 ` Arjan van de Ven
2006-07-25 18:43 ` Neil Horman
2006-07-25 18:53 ` Arjan van de Ven
2006-07-25 19:03 ` Neil Horman
2006-07-25 19:06 ` Arjan van de Ven
2006-07-25 19:07 ` John W. Linville
2006-07-25 19:16 ` Arjan van de Ven
2006-07-25 19:08 ` H. Peter Anvin
2006-07-25 17:57 ` Segher Boessenkool
2006-07-25 18:28 ` Neil Horman
2006-07-25 18:56 ` Segher Boessenkool
2006-07-25 19:07 ` Neil Horman
2006-07-25 19:10 ` H. Peter Anvin
2006-07-25 19:21 ` Neil Horman
2006-07-25 19:31 ` Segher Boessenkool
2006-07-25 19:47 ` Neil Horman
2006-07-25 20:04 ` Dave Airlie
2006-07-25 20:24 ` H. Peter Anvin
2006-07-25 20:47 ` Neil Horman
2006-07-25 20:50 ` H. Peter Anvin
2006-07-25 22:25 ` Neil Horman
2006-07-25 22:33 ` H. Peter Anvin
2006-07-25 23:10 ` Neil Horman
2006-07-25 23:22 ` H. Peter Anvin
2006-07-26 0:03 ` Neil Horman
2006-07-25 23:29 ` David Lang
2006-07-26 0:18 ` Neil Horman
2006-07-25 23:29 ` Segher Boessenkool
2006-07-25 23:56 ` Neil Horman
2006-07-26 0:02 ` H. Peter Anvin
2006-07-26 0:20 ` Neil Horman
2006-07-26 0:36 ` H. Peter Anvin
2006-07-26 14:45 ` Theodore Tso [this message]
2006-07-28 13:33 ` A better interface, perhaps: a timed signal flag Steven Rostedt
2006-07-28 14:52 ` Theodore Tso
2006-07-28 15:05 ` Steven Rostedt
2006-07-28 16:41 ` Alan Cox
2006-07-28 16:44 ` Steven Rostedt
2006-07-28 20:01 ` Alan Cox
2006-07-28 20:12 ` Steven Rostedt
2006-07-28 20:36 ` Alan Cox
2006-07-28 20:31 ` Steven Rostedt
2006-07-28 17:11 ` H. Peter Anvin
2006-07-25 20:58 ` [PATCH] RTC: Add mmap method to rtc character driver Jim Gettys
2006-07-25 21:04 ` H. Peter Anvin
2006-07-25 21:14 ` Jim Gettys
2006-07-25 21:18 ` H. Peter Anvin
2006-07-25 21:39 ` Jim Gettys
2006-07-29 4:28 ` Bill Huey
2006-07-29 12:54 ` Neil Horman
2006-07-29 20:41 ` Bill Huey
2006-07-29 21:43 ` Neil Horman
2006-07-29 22:45 ` Keith Packard
2006-07-29 23:18 ` Edgar Toernig
2006-07-29 21:49 ` Edgar Toernig
2006-07-29 22:51 ` itimer again (Re: [PATCH] RTC: Add mmap method to rtc character driver) Bill Huey
2006-07-29 23:35 ` Nicholas Miell
2006-07-30 1:00 ` Bill Huey
2006-07-30 1:22 ` Nicholas Miell
2006-07-30 1:39 ` Bill Huey
2006-07-30 2:02 ` Nicholas Miell
2006-07-30 14:33 ` Theodore Tso
2006-07-30 22:20 ` Bill Huey
2006-07-31 15:40 ` Theodore Tso
2006-07-30 0:16 ` Edgar Toernig
2006-07-30 0:24 ` Bill Huey
2006-07-29 14:02 ` [PATCH] RTC: Add mmap method to rtc character driver Thomas Gleixner
2006-07-26 13:17 ` Martin J. Bligh
2006-08-02 3:54 ` john stultz
2006-08-02 4:26 ` H. Peter Anvin
2006-08-02 4:34 ` john stultz
2006-07-25 23:26 ` Segher Boessenkool
2006-07-26 0:10 ` Neil Horman
2006-07-25 20:03 ` Paul Mackerras
2006-07-25 23:27 ` Segher Boessenkool
2006-07-26 0:06 ` Neil Horman
2006-07-25 18:00 ` Jim Gettys
2006-07-25 18:17 ` Neil Horman
2006-07-26 15:16 ` Andi Kleen
2006-07-26 17:25 ` Jim Gettys
2006-07-27 23:53 ` Paul Mackerras
2006-07-28 3:29 ` Jim Gettys
2006-07-28 11:59 ` Neil Horman
-- strict thread matches above, loose matches on Subject: below --
2006-07-26 15:15 A better interface, perhaps: a timed signal flag Brown, Len
2006-07-29 6:56 linux
[not found] <fa.xkoDc6Uvpcp6dnG8+9iwy53PPeo@ifi.uio.no>
[not found] ` <fa.7gpoVg9wmtQ0g4u4T8FaCZGXup0@ifi.uio.no>
2006-07-29 18:29 ` Robert Hancock
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=20060726144536.GA28597@thunk.org \
--to=tytso@mit.edu \
--cc=a.zummo@towertech.it \
--cc=airlied@gmail.com \
--cc=hpa@zytor.com \
--cc=jg@freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=segher@kernel.crashing.org \
/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