<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi<br>
<br>
Last week while teaching an RTEMS class, we looked at a SPARC BSP's<br>
get nanoseconds since last tick handler. They all follow this
pattern:<br>
<br>
<blockquote>clicks = Read Counter<br>
if ( clock interrupt pending ) {<br>
clicks = Read Counter;<br>
time =(2 * time per tick) - (clicks);<br>
} else {<br>
time = time per tick - clicks<br>
}<br>
<br>
return time;<br>
<br>
</blockquote>
The code is correct but I would like to add a comment to all three
versions<br>
of this code so it is clear what was intended.<br>
<br>
I think it is something like. Read the counter. If there is not an
interrupt pending,<br>
then we are in the same clock tick. If there is one pending, then
see how long<br>
past that tick we are. The handler has to report from slightly >
0 to slightly <br>
less than 2 ticks depending on where we are relative to the next
clock tick.<br>
<br>
Just wanting to make the code more understandable for the next
person. Help<br>
writing the comment is appreciated.<br>
<pre class="moz-signature" cols="72">--
Joel Sherrill, Ph.D. Director of Research & Development
<a class="moz-txt-link-abbreviated" href="mailto:joel.sherrill@OARcorp.com">joel.sherrill@OARcorp.com</a> On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985</pre>
</body>
</html>