[En-Nut-Discussion] NutEnterCritical vs NutEnterCriticalAccess()
Uwe Bonnes
bon at elektron.ikp.physik.tu-darmstadt.de
Tue Nov 17 11:10:02 CET 2015
Hello,
in our common code we use a lot of protection when accessing multi-byte
variables in drivers in user code when these variable can be changed by an
interrupt:
E.g. in dev/usart.c:UsartFlushOutput()
NutEnterCritical();
rc = rbf->rbf_cnt;
NutExitCritical();
However this access is atomic per se as long as the native bus width can
carry the variable. So on any of the 32-bit machines we support, these
critical sections are not needed. I propose to provide another machine
dependant call so that the usage above would change to something like
NutEnterCriticalAccess();
rc = rbf->rbf_cnt;
NutExitCriticalAccess();
On 8 bit machines these functions would resolve to NutEnterCritical()
and on 32-bit machines these functions would be empty defines.
Am I on a wrong track?
Any objections to provide the new functions in common code?
Probably changing existing drivers to use these new functions is prone to
colateral damage. Any opinions if it is worth to do that change?
Bye
--
Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 1623569 ------- Fax. 06151 1623305 ---------
More information about the En-Nut-Discussion
mailing list