Shared variable between a write thred and a read thread

Hello Everyone, I’ve read discussions about shared variable between threads in different topics. In each discussion I found that there are different ways to access to the shared variables. I understand that those ways are: – semaphore – mutex – queue In my application I have two threads: the first one thread writes a variable that has to be read from the second one thread. Also in this case, has to be use one of the previous method to shared data? Can someone help me to understand about sharing variable in my case? Regards, Giovanni.

Shared variable between a write thred and a read thread

If it is a single variable (rather than a structure or similar compound type), AND reading and writing the variable is an atomic operation (for example, reading a 32-bit value on a 32-bit architecture but not reading a 32-bit value on a 16-bit architecture), AND there is only one thread that writes to the variable (but any number of readers) – then you don’t need to use any RTOS primitives at all.