[En-Nut-Discussion] Not fixed!!!: Re: confirmed!!! Re: NutOS 4.4.0 on ARM7: possibly bug in NutEnterCritical / NutExitCritical

Nathan Moore nategoose at gmail.com
Thu Feb 21 15:56:26 CET 2008


> NutEnterCritical reads the CPSR and pushes it onto the stack.
> NutExitCritical pops one word from the stack and writes this value back
> to the CPSR.

> Since NutEnterCritical and NutExitCritical are #defines and not functions
> there is no guarantee that the code between Enter and Exit does not
> change the stackpointer. So in this case both the CPSR and the intended
> stack information will be wrong.

I had wondered about this on AVR, which is what we are using. A
wonderful way to ruin everything would be to use alloca( ) within a
critical section.
I think that it's really hard to get them right and allow critical
sections be reentrant without making the users of critical section
handle the status register data themselves  -- make NutEnterCritical
either return a value or take an OUT parameter and NutExitCritical
take an IN parameter.  Big change...

Nathan



More information about the En-Nut-Discussion mailing list