linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Real time clock update notification
@ 2012-01-27 22:52 Bob Richmond
  2012-01-28 14:26 ` Colin Walters
  0 siblings, 1 reply; 2+ messages in thread
From: Bob Richmond @ 2012-01-27 22:52 UTC (permalink / raw)
  To: linux-kernel

Is there any kind of facility for a process that is blocking in any one 
of the event notification system calls (select/poll/epoll_wait) to be 
unblocked in the event that the realtime clock has been updated? For 
instance, say I want to fire off an event at the exact moment that the 
realtime clock flips to 2pm. I first query the realtime clock via 
clock_gettime(CLOCK_REALTIME), and know that in 3 hours, it will be 2pm 
and I want to unblock at that moment. So I block in epoll_wait for 3 hours.

Then ntpd decides that the rtc is way off, and updates the current time 
to 1:30, and I should now be unblocking 30 minutes from now. However, my 
process can't know that this occurred and I should requery the rtc to 
find out how long I need to sleep *now*. It looks like crond (which 
performs a similar task) just wakes itself up every 60 seconds, which 
isn't particularly ideal.

If this facility doesn't exist, I'm curious whether something like it 
would be feasible to introduce with minimal overhead. I'm unsure how 
often ntpd resets the rtc when clock skew is detected, and my process 
might be excessively notified whenever the time changes by a few 
milliseconds.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Real time clock update notification
  2012-01-27 22:52 Real time clock update notification Bob Richmond
@ 2012-01-28 14:26 ` Colin Walters
  0 siblings, 0 replies; 2+ messages in thread
From: Colin Walters @ 2012-01-28 14:26 UTC (permalink / raw)
  To: Bob Richmond; +Cc: linux-kernel

On Fri, 2012-01-27 at 14:52 -0800, Bob Richmond wrote:
> Is there any kind of facility for a process that is blocking in any one 
> of the event notification system calls (select/poll/epoll_wait) to be 
> unblocked in the event that the realtime clock has been updated? For 
> instance, say I want to fire off an event at the exact moment that the 
> realtime clock flips to 2pm. I first query the realtime clock via 
> clock_gettime(CLOCK_REALTIME), and know that in 3 hours, it will be 2pm 
> and I want to unblock at that moment. So I block in epoll_wait for 3 hours.

You're looking for "timerfd".  Our use in GNOME is here:

http://git.gnome.org/browse/gnome-desktop/tree/libgnome-desktop/gnome-datetime-source.c


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-28 14:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-27 22:52 Real time clock update notification Bob Richmond
2012-01-28 14:26 ` Colin Walters

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).