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

Harald Kipp harald.kipp at egnite.de
Fri Feb 22 11:55:55 CET 2008


> Yes. As I understand the current implementation of NutEnterCritical /
> NutExitCritical the original value of the CPSR is saved on the stack to
> allow a later restore. This _must_ fail if the stack will be modified in
> the meanwhile.

I agree here as well and this is probably the cause of some strange 
behaviour happening when the code is compiled without optimization.

> Other operatin systems implement it the way you propose (e.g. Linux:
> spinlock_irq_save()) and save the flags in a variable you need to
> provide.

This is what I wanted to avoid, but haven't found any alternate solution 
so far.

Some time ago a contributor suggested a different solution, which is 
still in arch/h8300/include/atom.h. It adds an opening curly brace to 
NutEnterCritical and a closing one to NutExitCritical.  The intention 
was to avoid difficult to find problems due to any missing 
NutExitCritical(). Btw. that's also the reason for NutJumpOutCritical().

May be we can use this to add a local variable to NutEnterCritical. This 
may break some existing code, but avoids re-writing all the critical 


More information about the En-Nut-Discussion mailing list