Hello!
Can someone explain the meaning of NONATOMIC_BLOCK?
Does the NONATOMIC_BLOCK macro guarantee non-atomic code execution? Or does it simply allow its non-atomic execution inside the atomic one?
Hello!
Can someone explain the meaning of NONATOMIC_BLOCK?
Does the NONATOMIC_BLOCK macro guarantee non-atomic code execution? Or does it simply allow its non-atomic execution inside the atomic one?
I presume that you have seen this
Creates a block of code that is executed non-atomically. Upon entering the block the Global Interrupt Status flag in SREG is enabled, and disabled upon exiting the block from any exit path. This is useful when nested inside ATOMIC_BLOCK sections, allowing for non-atomic execution of small blocks of code while maintaining the atomic access of the other sections of the parent ATOMIC_BLOCK.
Two possible macro parameters are permitted, NONATOMIC_RESTORESTATE and NONATOMIC_FORCEOFF.
taken from NONATOMIC_BLOCK
Note particularly
allowing for non-atomic execution of small blocks of code while maintaining the atomic access of the other sections of the parent ATOMIC_BLOCK.
Have you got a particular set of circumstances under which you would want to use it ?
From the reference:
Creates a block of code that is executed non-atomically. Upon entering the block the Global Interrupt Status flag in SREG is enabled, and disabled upon exiting the block from any exit path. This is useful when nested inside ATOMIC_BLOCK sections, allowing for non-atomic execution of small blocks of code while maintaining the atomic access of the other sections of the parent ATOMIC_BLOCK.
And it would also not make sense to "guarantee non-atomic code execution". A single instruction task can't become non-atomic all of a sudden. And because of interrupts, are enaabled in normal operation, every task that's more than a single instruction is per definition non-atomic. Unless you disable interrupts for which you might use the ATOMIC_BLOCK and NONATOMIC_BLOCK macro's.
UKHeliBob:
Have you got a particular set of circumstances under which you would want to use it ?
...code blocks that are guaranteed to be excuted Atomically or Non-Atmomically
)