Date: Fri, 04 Oct 2019 14:10:48 +0000 From: "Poul-Henning Kamp" <phk@phk.freebsd.dk> To: Sebastian Huber <sebastian.huber@embedded-brains.de> Cc: Warner Losh <imp@bsdimp.com>, Konstantin Belousov <kostikbel@gmail.com>, Bruce Evans <brde@optusnet.com.au>, FreeBSD <freebsd-hackers@freebsd.org> Subject: Re: Why is tc_get_timecount() called two times in tc_init()? Message-ID: <60167.1570198248@critter.freebsd.dk> In-Reply-To: <141ee0af-2ff4-50fc-b4e4-6d1fc47e04f3@embedded-brains.de> References: <0e27fb3e-0f60-68e1-dbba-f17c3d91c332@embedded-brains.de> <20191002140040.GA44691@kib.kiev.ua> <20191003013314.O2151@besplex.bde.org> <20191002163946.GE44691@kib.kiev.ua> <20191003030837.C2787@besplex.bde.org> <20191003084021.GI44691@kib.kiev.ua> <CANCZdfpcOBJiYAKafhiWZS2g4vnLGVvzqhaOXetSSnU2Hj91nw@mail.gmail.com> <47834.1570116246@critter.freebsd.dk> <141ee0af-2ff4-50fc-b4e4-6d1fc47e04f3@embedded-brains.de>
next in thread | previous in thread | raw e-mail | index | archive | help
-------- In message <141ee0af-2ff4-50fc-b4e4-6d1fc47e04f3@embedded-brains.de>, Seba= stian 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() cal= ls? 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@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= .
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?60167.1570198248>