> Is there anyway to take care in the POSIX timers? Everything works fine
> with current time and the time move forwarded. The ticks doen't get
> generated when we change the time to backwards.
> Is this a known bug in POSIX timers? Do I need to take care something
> with flags.
> -Shiva
It is unfortunate that the timers in Solaris are such no matter what
behavior you are looking for from them, in the wake of a system clock
time step, you are going to be disappointed. There are two kinds of
behavior that the setitimer call is designed to deliver. The first is
to deliver an interrupt each time a certain interval passes. The
second is to deliver an interval at a certain time, say every minute,
on the minute.
In the first case, you probably do not want the timer to even notice
system clock changes. If you asked for "once each second", the
invariant you most likely want is that this current interrupt comes
one second after the last and one second before the next.
On the other hand, if you want "each minute, on the minute", you do
want the interrupt to be adjusted by the system clock.
However, in Solaris you get both and neither. If the clock is stepped
ahead by, say, one hour, the next interrupt will arrive at a time
that would have been the correct time before the clock stepped,
but the next interrupt will arrive at the correct time based on
the new system time.
So, suppose you wanted once each minute without regard to the
system clock, or once each minute, on the minute. Now suppose
that the clock is set backwards 5 minutes at 12:03:30. This is
when the interrupts would be delivered:
Wallclock Interval between this
and the previous interrupt.
11:59 60
12:00 60
12:01 60
12:02 60
12:03 60
( 12:03:30, clock set back 5 minutes to 11:58:30 )
11:59 60
12:05 300
So, if you wanted timer to fire each minute, you just got
300 seconds of no firing. If you wanted the timer to fire
each minute, on the minute, you just got number 11:59 twice.
What is really needed is for Solaris to split these two
types out and do the "right" thing for each of them.
I actually got involved with this problem because NTP
has the same problem! It uses setitimer to set up the
polling intervals, and it would stop polling when the
clock stepped backwards. However, we were able to solve
the problem for NTP, because, unlike other applications,
it knew when the clock stepped backwards, since it is
doing the stepping. We just stepped the clock and then
re-established the timer.
--
blu
"Having them stolen may become our distribution model..."
Nicolas Negroponte on the Hundred Dollar Laptop.
----------------------------------------------------------------------
Brian Utterback - OP/N1 RPE, Sun Microsystems, Inc.
Ph:877-259-7345, Em:brian.utterback-at-ess-you-enn-dot-kom