HELP: clock_gettime() problem?
Joel Sherrill
joel.sherrill at OARcorp.com
Mon Mar 8 17:57:37 UTC 2004
Alex wrote:
> Hi,
>
> Do you know why clock_gettime() POSIX call always returns the same value?
I am always amazed at how no matter what question or problem someone
has, someone else will ask it a few days later. It can go unasked
for years or a bug unnoticed for a long time and then... BAM! :)
This was discussed in this thread a few days ago
http://www.rtems.com/ml/rtems-users/2004/march/msg00013.html
You probably are missing the line to configure a clock device driver.
And with 10 millisecond clock ticks, you are also subject to this:
> FWIW the accuracy of the RTEMS timeofday is configurable
> in number of microseconds. It defaults to 10 milliseconds.
> CONFIGURE_MICROSECONDS_PER_TICK is the macro. When you
> do a gettimeofday() it only looks at whole clock ticks and
> does not touch the HW to determine any partial clock tick
> amounts.
I am willing to discuss an optional BSP specific hook to return
nanoseconds since the last clock tick if the general consensus
is that it is needed.
--joel
> See next example:
>
> #include <bsp.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <time.h>
>
> ...
>
> //GET START TIME
> clock_gettime( CLOCK_REALTIME, &start );
>
> clock_getres(CLOCK_REALTIME, &resolution);
> //Some active huge delay...
> for(j=0;j<100000;j++)
> {
> for(i=0;i<1000000;i++)
> cI=cI%status;
> }
>
> //GET STOP TIME
> clock_gettime( CLOCK_REALTIME, ¤t );
>
> ...
>
>
> Every time I execute the program I always get the following values:
>
> start.tv_sec=567993600
> start.tv_nsec=0
>
> current.tv_sec=567993600
> current.tv_nsec=0
>
> Why?
>
> Thanks a lot...
>
> Alex
>
>
> PS1: rtems version=4.6; bsp=pc686; in a i686 computer
> PS2: the clock_getres(CLOCK_REALTIME,&resolution) call
> returns tv_sec=0, tv_nsec=10.000.000
>
>
> ___________________________________________________________________________________________
> IOL Flash. A net normal em versao acelerada.
> Precisa de uma caixa de correio maior? Com o IOL Flash pode ter uma caixa com 21MB de espaco.
> Saiba mais sobre o IOL Flash: http://www.iol.pt/central_utilizador/iol_flash/
>
More information about the users
mailing list