Handle Global Memory

canalrun wrote on Wednesday, February 27, 2019:

Hello,
I am brand-new to Free RTOS. I have two questions.

  1. I am using an Adafruit Feather ESP32 board purchased in Feb 2019 with the newest Arduino 1.8.8 IDE. I ran the simple examples from Random Nerd Tutorials and they worked using RTOS calls – so I guess I have it installed. Does this make sense? Do I have it installed? Or, am I fooling myself?

  2. I plan to run two tasks on my ESP32. Core 0 will continually acquire ADC samples and store them in ping-pong buffers. Core 1 (within Loop()) will check a buffer position and/or full variable and perform FFT’s on the data. This requires a few global variables: the buffers, and the buffer position/full variables. Core 0 will be the only writer. Both core 0 and core 1 will read the variables.

Do global memory variables require mutexes or semaphores? The reads or writes will be atomic – either 16 or 32 bit integers.

Thanks,
Barry.

rtel wrote on Wednesday, February 27, 2019:

I have no idea about the platform or the software you are running on
… but to answer your question: Generally if you have multiple
readers but only one writer to a single value (rather than a structure)
then you do not need a critical section provided the value can be
written in one go (i.e. a 32-bit write on a 32-bit architecture can be
written in one go, whereas a 64-bit value on a 32-bit architecture
cannot). On the other hand if you have multiple writers then you would
need a critical section.