[ntp:questions] Re: Time set backward

Garrett Wollman wollman at csail.mit.edu
Fri Jan 6 21:59:06 UTC 2006


In article <dpmna9$6h8$1 at dewey.udel.edu>,
David L. Mills <mills at udel.edu> wrote:
>I don't understand how POSIX can implement a time of day function using 
>timers.

It does precisely the opposite: timers are implemented in terms of the
TOD.

Here's what the standard says:

# Each implementation shall define a set of clocks that can be used as
# timing bases for per-process timers. All implementations shall
# support a clock_id of CLOCK_REALTIME. If the Monotonic Clock option
# is supported, implementations shall support a clock_id of
# CLOCK_MONOTONIC.

(timer_create, XSI6 page 1514, IEEE Std.1003.1-2001)

# 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.

(timer_getoverrun [sic], XSI6 page 1518, IEEE Std.1003.1-2001)

# If the value of the CLOCK_REALTIME clock is set via clock_settime( ),
# the new value of the clock shall be used to determine the time of
# expiration for absolute time services based upon the CLOCK_REALTIME
# clock. This applies to the time at which armed absolute timers
# expire. If the absolute time requested at the invocation of such a
# time service is before the new value of the clock, the time service
# shall expire immediately as if the clock had reached the requested
# time normally.

# Setting the value of the CLOCK_REALTIME clock via clock_settime( )
# shall have no effect on threads that are blocked waiting for a
# relative time service based upon this clock, including the
# nanosleep( ) function; nor on the expiration of relative timers
# based upon this clock.  Consequently, these time services shall
# expire when the requested relative interval elapses, independently
# of the new or old value of the clock.

(clock_getres [sic], XSI6 page 195, IEEE Std.1003.1-2001)

-GAWollman

-- 
Garrett A. Wollman    | As the Constitution endures, persons in every
wollman at csail.mit.edu | generation can invoke its principles in their own
Opinions not those    | search for greater freedom.
of MIT or CSAIL.      | - A. Kennedy, Lawrence v. Texas, 539 U.S. 558 (2003)




More information about the questions mailing list