Why is tc_get_timecount() called two times in tc_init()?

Poul-Henning Kamp phk at phk.freebsd.dk
Fri Oct 4 14:10:54 UTC 2019


--------
In message <141ee0af-2ff4-50fc-b4e4-6d1fc47e04f3 at embedded-brains.de>, Sebastian
 Huber writes:

>> I think the original reason for this was (locked) delta-based
>> timecounters, (ie counters which roll over rapidly) in order that
>> their first "real" use would not return truly bogus values.
>
>Ok, this explanation makes sense. When I ported the FreeBSD timecounter 
>implementation to RTEMS I was a bit surprised how many chips (even a 
>Cortex-M has nothing out of the box) lack a simple free running counter. 
>Maybe it should be added as a comment to these two tc_get_timecount() calls?

As long as the counter can be read atomically and does not roll over
in a matter of milliseconds, two reads are not necessary.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the freebsd-hackers mailing list