This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Re: Problem on converting a "timespec" struct to a number of ticks
- From: Andrew Lunn <andrew at lunn dot ch>
- To: e dot coullien at faiveley dot com
- Cc: ecos-patches at ecos dot sourceware dot org, b dot aubert at faiveley dot com
- Date: Sat, 25 Sep 2004 13:12:29 +0200
- Subject: Re: Problem on converting a "timespec" struct to a number of ticks
- References: <C1256F17.0054F7D5.00@smtp.faiveley.fr>
On Wed, Sep 22, 2004 at 05:28:04PM +0200, e.coullien@faiveley.com wrote:
>
>
> Function "cyg_timespec_to_ticks()" belongs to "time.cxx", part of
> POSIX compatibility package. This function converts a "timespec"
> struct to a number of ticks. The "timespec" struct is used to
> express a duration or a delay in nanoseconds.
>
> When testing POSIX compatibility package, the following behavior can
> be observed : 15.000.001 nanosecondes are converted to 3 system
> ticks (the system tick is set to 10 ms). The result should be 2
> ticks (20 ms),
>
> We want to achieve better accuracy of this function. As it is called
> by "nanosleep()", the accuracy of our delays relies on
> "cyg_timespec_to_ticks()".
>
> The behavior we expect from "cyg_timespec_to_ticks()" is described
> by the table below :
>
> nanoseconds ticks
> 19.999.999 2
> 20.000.000 2
> 20.000.001 3
> 29.999.999 3
> 30.000.000 3
>
> The roundup is always made to the next integer value. When the number of
> nanoseconds is an exact number of ticks, no roundup is necessary.
Thats is what i would expect to happen. Could you tell us what is
actually happening with the current code. I like to understand what it
wrong before applying a fix. Since you have effectively re-written the
code it hard for me to see what was wrong with it.
> Up to now, "cyg_timespec_to_ticks()" calls the "convert()" function
> (file "clock.inl", "kernel" package). Now, this (complicated)
> function is no more used at all.
When eCos is complicated, there is generally a reason. It makes me
wonder if you simple code might be wrong for the same reason.
Please could you send diff -u next time. They are much easier to read.
Thanks
Andrew