> I am sorry for misreading 32 bits (4 bytes) as 32 bytes. That is > obviously very different. If Microsoft's malloc is sufficient, why does > MSDN tell us to use _aligned_malloc instead of malloc? I don't know. Perhaps they assume that people may be using alternative malloc implementations, or (more likely) people in the platform group are unaware of the guarantees the compiler group makes (because of compliance with the C standard). > Obvious usecases for volatile are: > > - Implementation of a spinlock, where register allocation is detrimental. Unfortunately, that's not true. It's not really possible to implement a spinlock in C if the processor can make changes to the write ordering. > - A buffer that is filled from the "outside" with some DMA mechanism. > - Real-time programs and games where order of execution and and timing > is critical, so optimization must be supressed. Likewise. On many current processors, you have to use fencing instructions to make this kind of stuff work, something that the compiler will not normally generate (except through inline assembly). > Even though volatile is not needed for processing within a critical > section, we still need the shared data to be re-loaded upon entering and > er-written upon leaving. Please see the code. Where exactly does such reloading/rewriting need to happen? Regards, Martin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4