[En-Nut-Discussion] NutEnterCritical vs NutEnterCriticalAccess()

Philipp Burch phip at hb9etc.ch
Tue Nov 17 17:02:41 CET 2015

Hi Ole!

On 17.11.2015 15:42, Ole Reinhardt wrote:
> Hi Uwe,
> I suspect you are on the wrong track. In my understanding assigning the
> value of one variable to another will result at least in one load and
> one store operation on ARM.
> Even more, if one of the variables uses indirect addressing (like in
> your example)
> [...]

My guess is that Uwe isn't talking about concurrent bidirectional
access, but more something like producer/consumer. So maybe something like

int val;

void f(void) {
  // ...
  val = 42;
  // ...

ISR(my_int) {
  int x;
  // ...
  x += val;
  // ...

In this case, there is no requirement for a critical section if the CPU
can atomically write (or generally just access) the whole memory
location containing "val". No matter if it's directly or indirectly
addressed. This wouldn't hold if the interrupt would write back to "val"
or if the other code would access val more than once like in a
read-modify-write operation, of course.

The proposed change could help to reduce interrupt latency and probably
save some cycles, but I doubt that the impact would be very large.
Depends on the driver code, obviously.


More information about the En-Nut-Discussion mailing list