This is the mail archive of the
ecos-discuss@sourceware.cygnus.com
mailing list for the eCos project.
RE: Timer tick length
- To: Grant Edwards <grante at visi dot com>
- Subject: RE: [ECOS] Timer tick length
- From: Gary Thomas <gthomas at redhat dot com>
- Date: Tue, 04 Apr 2000 12:33:59 -0600 (MDT)
- Cc: ecos-discuss at sourceware dot cygnus dot com
On 04-Apr-00 Grant Edwards wrote:
>
>> > If I go with that configuration when I run the ping_test, I get
>> > "recvfrom: Operation timed out" messages quite quickly -- it
>> > takes less than 2 seconds for all 16 timeouts. Does the TCP/IP
>> > stack assume that a clock tick is 10ms? (On my system it's
>> > 1ms.)
>>
>> Yup. We [currently] don't have a good way to tell the length
>> of a tick.
>
> The problem of application code not knowing how long a "tick"
> is seems to keep popping up. In most other RTOS systems I've
> used, there was a constant or a pair of macros defined in a
> header that allowed application code to convert between ticks
> and "real" time (seconds or milliseconds). This allowed one to
> write code that didn't break when the length of a clock tick
> was changed.
>
> I think the eCos really needs something like that. I've had to
> change the tick value back and fourth several times to
> accomodate different application code. It's currently at 10ms
> to allow the TCP/IP stack to work, but I'll have to come up
> with a way to get it back to 1ms so that other portions of my
> application will work correctly and yet keep TCP/IP working.
>
> Any thoughts on providing a way to let application code know
> how long a tick is?
>
The information _is_ there, it's just not pretty.
Here's how to get at it (culled from ecc/kernel/XXX/tests/tm_basic.cxx):
#include <pkgconf/kernel.h>
long rtc_resolution[] = CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION;
long ns_per_system_clock;
// To convert system clock 'ticks' to nanoseconds (ns)
ns_per_system_clock = 1000000/rtc_resolution[1];
ns = (ns_per_system_clock * (long long)ticks) / CYGNUM_KERNEL_COUNTERS_RTC_PERIOD;
Does this suffice?