Question on all SPARC BSP get nanoseconds handler

Joel Sherrill joel.sherrill at oarcorp.com
Mon Feb 2 17:45:04 UTC 2015


Hi

Last week while teaching an RTEMS class, we looked at a SPARC BSP's
get nanoseconds since last tick handler. They all follow this pattern:

    clicks = Read Counter
    if ( clock interrupt pending ) {
     clicks = Read Counter;
      time =(2 * time per tick) - (clicks);
    } else {
      time = time per tick - clicks
    }

    return time;

The code is correct but I would like to add a comment to all three versions
of this code so it is clear what was intended.

I think it is something like. Read the counter. If there is not an
interrupt pending,
then we are in the same clock tick. If there is one pending, then see
how long
past that tick we are. The handler has to report from slightly > 0 to
slightly
less than 2 ticks depending on where we are relative to the next clock tick.

Just wanting to make the code more understandable for the next person. Help
writing the comment is appreciated.

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20150202/ddb2ef1a/attachment-0001.html>


More information about the devel mailing list