Hi,
I would like to know if when we store a value in uint32_t variable it's an atomic operation or not with esp32 ?
How to know which variable type is atomic and which not ?
Is uint32_t atomic ?
Re: Is uint32_t atomic ?
Hi Cupcake,
Reads and writes will be atomic (the compiler generates 32-bit load and store operations.)
Updating (read/modify/write) is not atomic. You can either use a FreeRTOS "portmux" and critical section to protect access to the variable, or use the standard C atomic API in stdatomic.h to perform an atomic update operation.
Reads and writes will be atomic (the compiler generates 32-bit load and store operations.)
Updating (read/modify/write) is not atomic. You can either use a FreeRTOS "portmux" and critical section to protect access to the variable, or use the standard C atomic API in stdatomic.h to perform an atomic update operation.
Re: Is uint32_t atomic ?
Can you confirm if this is the case for memory used by threads on different cores?
If each read/write is atomic, does this apply when each core reads or writes simultaneously?
If each read/write is atomic, does this apply when each core reads or writes simultaneously?
Re: Is uint32_t atomic ?
Yes, it does. If both cores write to the same 32-bit variable, the value should hold either the value written by one core or the other, not a mix of the two values.
Similarly, if one core reads while the core writes then it should see either the old 32-bit value or the new 32-bit value, not a mix of the two.
Who is online
Users browsing this forum: Baidu [Spider], BipinDangwal, Google [Bot], ignisuti, MicroController and 119 guests