Hi,
I have CMSIS RTOS thread increment uint32_t variable.
Other thread is reading uint32_t variable.
Do I need to use mutex to protected these read and write.
Can I use any better way without using OS mutex.
Thanks, Naeem
NO.
A INCREMENT IS A READ OPERATION WRITE SEQUNCE.
IT CAN BE INTURUPTED IN TEH SEQENCE.
YOU MUST PROTECT SOME WAY.
Make sure the variable is volatile.
If you just increment it in one place(thread), and read it in multiple places, then you don't need a mutex.
Mutex won't help if you are interrupting the holder.
>>Can I use any better way without using OS mutex. Don't have multiple threads increment the variable?
Thanks guys foe your input.
I only have one thread changing variable.
volatile will work without mutex.