4 ms·
I may not properly understand what you're saying because i haven't had to deal with volative keywords. However, i'm surprised by what (i think i understood from
by bsaul 2y ago
I may not properly understand what you're saying because i haven't had to deal with volative keywords. However, i'm surprised by what (i think i understood from what) you're saying: aren't all register restored on process switching ?
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- foldr 2y agoIf two pieces of code are accessing irq_flags concurrently then the load and store operations from each may be interleaved, giving incorrect results.
- bsaul 2y agoOk but what makes it specific to volatile ? This pb happens with all memory. Are volatile variables used for atomic memory access semantic ?
- deleted 2y ago[deleted]
- foldr 2y agoI guess the point was that in the case of a non-volatile variable, the variable would typically be in a register and the compiler would typically compile foo |= CONSTANT into a single instruction (though there is no guarantee of any of this). But if the variable is volatile then the compiler would have to load it from memory into a register, perform the bitwise operation, and then store it again. If irq_flags represents a memory mapped register then you'd need to force the second option.