You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think we may need to add memory barrier to xt_rsil().
Based on the comments I saw here:
From ESP8266_RTOS_SDK/components/esp8266/include/xtensa/xtruntime.h
/* NOTE: these asm macros don't modify memory, but they are marked * as such to act as memory access barriers to the compiler because * these macros are sometimes used to delineate critical sections; * function calls are natural barriers (the compiler does not know * whether a function modifies memory) unless declared to be inlined. */
# defineXTOS_SET_INTLEVEL(intlevel) ({ unsigned __tmp; \
__asm____volatile__( "rsil %0, "XTSTR(intlevel) "\n" \
: "=a" (__tmp) : : "memory" ); \
__tmp;})
After trying to get a better understanding of the "memory" parameter. I think the current xt_rsil() in
I wanted to see the results in assembly. So I did a quick compile to .S of this sample function with the old xt_rsil() and one with "memory" specified:
Sorry, I am not sure of the question? The 1st .S is without the memory barrier/fence. The 2nd .S with the barrier/fence. And of course xt_wsr_ps() already had the "memory" fence parameter.
Based on what I see in the assembly, the temporary registers that are loaded with values from memory are not shared across memory barriers. I didn't fully grasp the significance of what I read until I saw how the code changed in assembly.
BTW: I assume some rules must exist on how to apply memory fences defined in a class constructor and destructor to the context of the scope. With the test function I built, using the InterruptLock class (with the "memory" parameter), the resulting .S appeared to be correct.
I think we may need to add memory barrier to
xt_rsil()
.Based on the comments I saw here:
From
ESP8266_RTOS_SDK/components/esp8266/include/xtensa/xtruntime.h
After trying to get a better understanding of the "memory" parameter. I think the current
xt_rsil()
inArduino/cores/esp8266/Arduino.h
Line 162 in cd6cf98
needs it.
I wanted to see the results in assembly. So I did a quick compile to .S of this sample function with the old
xt_rsil()
and one with "memory" specified:Using
xt_rsil()
without "memory" fence, trimmed .S results:Using
xt_rsil()
with "memory" fence, trimmed .S results:Notice the change.
*a
outside the critical area. Then saves that value to*b
while in the critical area.*a
outside the critical area. However, while in the critical area it reads*a
again before saving it to*b
.Originally posted by @mhightower83 in #6274 (comment)
The text was updated successfully, but these errors were encountered: