Keywords that may change the behaviours of Compiler or program
volatile
Used to indicate to the Compiler that a variable’s value may change unexpectedly
Often the case when a variable is being accessed by multiple Thread or when it represents hardware that is external to the computer
Compiler will not optimize the code that accesses the variable. This means that the compiler will not reorder instructions or eliminate redundant reads or writes to the variable
This can be important for ensuring that the variable’s value is always read and written correctly
Example: In the below example, we have 2 exact same Instruction, for performance sake, Compiler will remove the second one since it doesn’t cause side effect inside the uartinit() function. However, this will cause us unable to set the Baud Rate!