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.sherr...@oarcorp.com On-Line Applications Research Ask me about RTEMS: a free RTOS Huntsville AL 35805 Support Available (256) 722-9985
_______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel