Volatile : Source code to assembly, Processor execution flow

In C programming, a volatile variable can change its value unexpectedly due to multiple threads, modification by an external device, or an external process. The tutorial analyzes and compares how the assembly output, compiled from C source code, differs based on the use of a volatile int variable and a non-volatile int variable. Volatile variables can affect compiler optimizations and are frequently used in embedded systems where the most current variable value is crucial. The choice to use volatile or not depends on the program's specific requirements and the expected behavior of the variables.

Oops ! Volatile

While translating source code to machine code, compiler applies various optimisations. Compiler cleans excess machine code to reduce executable size and increase speed of execution, saves memory, CPU cycle etc. if a variable needs to be changed from outside compiler should not apply optimisation, since an optimisation might not check the variable at all in… Continue reading Oops ! Volatile