<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
That was it.  Our version of ckinit.c doesn't have the bug fix.
<div class=""><br class="">
</div>
<div class="">Thanks, Joel.   As always, appreciate your support.</div>
<div class=""><br class="">
</div>
<div class="">We were doing some algorithm timing, and weren't sure whether we could trust the results.  Appears that we can, just knowing that we need to either fix or account for this anomaly happening sometimes.</div>
<div class=""><br class="">
</div>
<div class="">Scott</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">--</div>
<div class=""><br class="">
</div>
<div class="">Scott Miller | 210-522-4249 | Senior Research Engineer | Southwest Research Institute </div>
</div>
<div class="">
<div><br class="">
<div class="">Begin forwarded message:</div>
<br class="Apple-interchange-newline">
<div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class="">
<span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">From:
</b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">Joel Sherrill <<a href="mailto:joel.sherrill@oarcorp.com" class="">joel.sherrill@oarcorp.com</a>><br class="">
</span></div>
<div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class="">
<span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">Subject:
</b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class=""><b class="">Re: clock_gettime() result going backwards on LEON3?</b><br class="">
</span></div>
<div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class="">
<span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">Date:
</b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">June 23, 2015 at 10:06:54 AM CDT<br class="">
</span></div>
<div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class="">
<span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif; color:rgba(0, 0, 0, 1.0);" class=""><b class="">To:
</b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">"Miller, Scott A." <<a href="mailto:scott.miller@swri.org" class="">scott.miller@swri.org</a>>, "<a href="mailto:users@rtems.org" class="">users@rtems.org</a>"
 <<a href="mailto:users@rtems.org" class="">users@rtems.org</a>><br class="">
</span></div>
<br class="">
<div class=""><br class="">
<br class="">
On 6/23/2015 9:48 AM, Miller, Scott A. wrote:<br class="">
<blockquote type="cite" class="">It was actually pulled before I joined the project, so I am a bit fuzzy on the details, but I believe October 2013.    It appears to be a download of the RCC from Gaisler.  Here's VERSION:<br class="">
<br class="">
samiller@buttercup:/project/RTEMS/rtems-4.10$ cat VERSION<br class="">
RCC-1.1.99.12a. RTEMS-4.10, GCC 4.3.3<br class="">
</blockquote>
<br class="">
There is a PR for that and I think it is fixed on the branch.<br class="">
<br class="">
The simplest way to check is to clone the repo, check out the branch<br class="">
and look at the history for leon3/clock/ckinit.c. I suspect the code<br class="">
in bsp_clock_nanoseconds_since_last_tick() will look different from<br class="">
what you have. It tracks back to this change:<br class="">
<br class="">
   2011-03-04  Joel Sherrill <<a href="mailto:joel.sherrilL@OARcorp.com" class="">joel.sherrilL@OARcorp.com</a>><br class="">
           PR 1748/bsps<br class="">
       * clock/ckinit.c, include/leon.h: When the clock tick generates an<br class="">
       interrupt WHILE we have interrupts disabled doing a get TOD or<br class="">
       uptime, the get nanoseconds handler was returning a bogusly large<br class="">
       number.<br class="">
<br class="">
Assuming what you have is 4.10 plus some patches. It is likely missing this<br class="">
one.<br class="">
<br class="">
If that doesn't do it, then either I am guessing the wrong rtems version<br class="">
or we have a different issue.<br class="">
<br class="">
Recently 4.11 has had time rework and this code was touched again. So if<br class="">
you are using the git master, the problem and solution will be different.<br class="">
<br class="">
<br class="">
<blockquote type="cite" class="">Scott<br class="">
<br class="">
On Jun 23, 2015, at 9:39 AM, Joel Sherrill <<a href="mailto:Joel.Sherrill@OARcorp.com" class="">Joel.Sherrill@OARcorp.com</a>> wrote:<br class="">
<br class="">
<br class="">
<br class="">
On 6/23/2015 9:11 AM, Miller, Scott A. wrote:<br class="">
<blockquote type="cite" class="">Hello,<br class="">
<br class="">
I'm observing that intermittently, that two successive calls to clock_gettime() will result in the 2nd timespec result being "before" the 1st timespec result.<br class="">
<br class="">
Here's the code and some example output showing this:<br class="">
<br class="">
<code snippet><br class="">
<br class="">
#include <rtems.h><br class="">
#include <bsp.h><br class="">
#define CONFIGURE_INIT<br class="">
<br class="">
rtems_task Init(rtems_task_argument ignored);<br class="">
<br class="">
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER<br class="">
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER<br class="">
#define CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER      1<br class="">
#define CONFIGURE_INIT_TASK_ATTRIBUTES               RTEMS_FLOATING_POINT<br class="">
#define CONFIGURE_INIT_TASK_STACK_SIZE               (10 * RTEMS_MINIMUM_STACK_SIZE)<br class="">
#define CONFIGURE_MAXIMUM_TASKS                      13<br class="">
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE<br class="">
#define CONFIGURE_MAXIMUM_DRIVERS                    16<br class="">
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS     32<br class="">
#define CONFIGURE_EXTRA_TASK_STACKS                  (10 * RTEMS_MINIMUM_STACK_SIZE)<br class="">
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES              rtems_resource_unlimited(10)<br class="">
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES  rtems_resource_unlimited(10)<br class="">
#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES           rtems_resource_unlimited(10)<br class="">
#define CONFIGURE_UNIFIED_WORK_AREAS<br class="">
#include <rtems/confdefs.h><br class="">
<br class="">
....<br class="">
<br class="">
    struct timespec time1;<br class="">
    struct timespec time2;<br class="">
    uint32_t i = 0;<br class="">
<br class="">
    while (TRUE) {<br class="">
        clock_gettime(CLOCK_REALTIME, &time1);<br class="">
        clock_gettime(CLOCK_REALTIME, &time2);<br class="">
<br class="">
        if (time1.tv_sec == time2.tv_sec) {<br class="">
            if (time2.tv_nsec < time1.tv_nsec) {<br class="">
                PRINTF("Violation!\n");<br class="">
                PRINTF("%09u - %09u\n", time1.tv_sec, time1.tv_nsec);<br class="">
                PRINTF("%09u - %09u\n", time2.tv_sec, time2.tv_nsec);<br class="">
            }<br class="">
        }<br class="">
<br class="">
        i++;<br class="">
<br class="">
        if (0 == (i % 1000)) {<br class="">
            PRINTF("Completed %d iterations...\n", i);<br class="">
        }<br class="">
    }<br class="">
<br class="">
</code snippet><br class="">
<br class="">
<output><br class="">
<br class="">
(gdb) run<br class="">
Completed 1000 iterations...<br class="">
Completed 2000 iterations...<br class="">
Completed 3000 iterations...<br class="">
Violation!<br class="">
000000000 - 169994000<br class="">
000000000 - 160002000<br class="">
Completed 4000 iterations...<br class="">
Completed 5000 iterations...<br class="">
Completed 6000 iterations...<br class="">
Violation!<br class="">
000000000 - 409994000<br class="">
000000000 - 400002000<br class="">
Completed 7000 iterations...<br class="">
Completed 8000 iterations...<br class="">
Completed 9000 iterations...<br class="">
Completed 10000 iterations...<br class="">
Completed 11000 iterations...<br class="">
Violation!<br class="">
000000000 - 769993000<br class="">
000000000 - 760001000<br class="">
<br class="">
</output><br class="">
<br class="">
I'm running RTEMS 4.10.99 against the LEON3 (GR712RC) BSP.<br class="">
<br class="">
Is this expected behavior, or am I doing something incorrectly?<br class="">
</blockquote>
<br class="">
No it is not expected.<br class="">
<br class="">
What date did you pull the code? Is it up to date?<br class="">
<br class="">
<blockquote type="cite" class="">Thanks.<br class="">
<br class="">
Scott<br class="">
<br class="">
--<br class="">
<br class="">
Scott Miller | 210-522-4249 | Senior Research Engineer | Southwest Research Institute<br class="">
_______________________________________________<br class="">
users mailing list<br class="">
<a href="mailto:users@rtems.org" class="">users@rtems.org</a><br class="">
http://lists.rtems.org/mailman/listinfo/users<br class="">
<br class="">
</blockquote>
<br class="">
</blockquote>
<br class="">
-- <br class="">
Joel Sherrill, Ph.D.             Director of Research & Development<br class="">
<a href="mailto:joel.sherrill@OARcorp.com" class="">joel.sherrill@OARcorp.com</a>        On-Line Applications Research<br class="">
Ask me about RTEMS: a free RTOS  Huntsville AL 35805<br class="">
Support Available                (256) 722-9985<br class="">
</div>
</div>
<br class="">
</div>
</body>
</html>