Commit 30e2e70
committed
OS/FreeRTOS: add volatile to recursive spinlock tracking arrays
The `ucOwnedByCore` and `ucRecursionCountByLock` arrays are used to
manage recursive spinlocks and are accessed by multiple cores.
Without the `volatile` keyword, the compiler might optimize away memory
accesses and cache the array values in registers. This could lead to
a core reading a stale value, causing incorrect lock behavior, race
conditions, or deadlocks in a multi-core environment.
Marking these arrays as `volatile` ensures that every access reads from
or writes to main memory, guaranteeing the correct and up-to-date
state is observed by all cores.
Signed-off-by: Huaqi Fang <[email protected]>1 parent 4648578 commit 30e2e70
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| |||
0 commit comments