Bug in Posix clock_getres.c
David Polock
polock at uni-koblenz.de
Tue Oct 9 07:59:13 UTC 2001
Hi,
I've just started to take a look at rtems, version 4.5.0. I think I've found
a bug in rtems-4.5.0/c/src/exec/posix/src/clockgetres.c. If the mailing list
is not the right place for bug reports, please point me to the correct address.
------------------
Bug description:
The function clock_getres should calculate the resolution of a time unit. The
result is stored in a timespec structure. The operating system stores the timer
resolution in _TOD_Microseconds_per_tick.
clockgetres.c:40 reads:
>> _POSIX_Interval_to_timespec( _TOD_Microseconds_per_tick, res );
The function _POSIX_Interval_to_timespec expects "ticks" and calculates the
corresponding time in microsecons with the line
>> usecs = ticks * _TOD_Microseconds_per_tick;
So the abstract effect of these calls is:
>> res = _TOD_Microseconds_per_tick * _TOD_Microseconds_per_tick
So the returned clock resolution is the squared value of the real clock resolution.
------------------
Bug fix:
Change line 40 in clockgetres.c to:
>> _POSIX_Interval_to_timespec( 1, res );
Best regards,
David Polock
More information about the users
mailing list