NutEnterCritical vs NutEnterCriticalAccess()

Uwe Bonnes <bon-1JbLm1bU5j5ZIx36JBfelj3+ndqKAYMe9FMPySWZwLkb1SvskN2V4Q@public.gmane.org>
Newsgroups gmane.comp.hardware.microcontrollers.ethernut
Message-ID <[email protected]>
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-1JbLm1bU5j5ZIx36JBfelj3+ndqKAYMe9FMPySWZwLkb1SvskN2V4Q@public.gmane.org

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 1623569 ------- Fax. 06151 1623305 ---------
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.