This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

gettimeofday()

I am trying to get some basic timing in a dsplink application.  When I use gettimeofday() on the arm side of the app, the tv_usec field returned in timeval is sometimes negative, and the values I do get don't necessarily make much sense.  I'm using a slightly modified version of the loop application to perform these benchmarks.

When I use gettimeofday() in a standalone arm application, it seems to work fine.

Any clue what I should look at?

Thanks,

Chris

  • Chris,

    Are you saying that the tv_usec difference (between successive timeval's returned from successive gettimeofday() calls) is negative, or that the absolute value returned from one gettimeofday() call is negative?  Using DSPLink shouldn't change the behavior of gettimeofday(), as that function comes from the glibc library.  The tv_usec field should always be less than one million, but I don't think it should be negative.

    This code from the GNU libc manual might give correct results if subtracting two timeval returns is the issue.

    Regards, Daniel

  • Daniel,

    Thanks for the tip.  I had used this page to grab the algorithm I was already using, but didn't give it much thought.  You prompted me to give another look -- there are side effects in that solution, because the structures containing the start and end times are being passed in as pointers.   This caused some problems that ultimately gave me negative results.

    Thanks,

    Chris