Re: NutEnterCritical vs NutEnterCriticalAccess()

Philipp Burch <[email protected]>
Newsgroups gmane.comp.hardware.microcontrollers.ethernut
Message-ID <[email protected]>
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.

Cheers,
Philipp
_______________________________________________
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.