This is the mail archive of the mailing list for the eCos project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Absolute vs. relative tick count.

Hello there,

For NTP to work accurately, we need to be able to call clock_settime()
defined in .../compat/posix/current/src/time.cxx.

Subsequent calls to e.g. gettimeofday() and clock_gettime() will then
return the absolute time set with the call to clock_settime().

The clock_settime() function calls
Cyg_Clock::real_time_clock->set_value(), which in turn changes the
Cyg_RealTimeClock class' counter member inherited from Cyg_Counter. So
far so good.

The problem is that changing the counter member has some side-effects:
cyg_current_time(), for instance, starts returning the new tick count,
which causes threads to time-out sooner than expected, and alarms/timers
created with timer_settime() or directly with the Cyg_Alarm() class
might start behaving strangely.

An alternative to using clock_settime() is to use
cyg_libc_time_settime(), which uses the WallClock (with the emulated
device) for storing the time. The problem with this approach is that a
call to time(NULL) won't roll-over to the next second at the correct
point in time (it has a 1 second resolution), and a call to
Cyg_WallClock::init_hw_seconds() won't help us much, I think.

I'd really like to have two counters in the Cyg_RealTimeClock (or one of
its parent classes): One that can be changed with a call to
clock_settime()/Cyg_Clock::real_time_clock->set_value() and one that
counts the number of ticks since boot and can't be changed. There should
also be two sets of functions for obtaining these values depending on
whether they're going to be used in e.g. gettimeofday() or for

Any suggestions/ideas would be very helpful.

Thanks in advance,
Rene Schipp von Branitz Nielsen
Vitesse Semiconductors

Before posting, please read the FAQ:
and search the list archive:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]