This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is increment uint32_t atomic operation

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

Parents
  • 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?

Reply
  • 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?

Children