valatile variables
c++ compiler optimize code by using allocating
the cpu registers to variables. keeping frequently used variables in registers improve the performance. programmer can also
provide hint to compiler by declaring a variable as register (using register keyword).
the qualifier volatile tells the compiler “You never know when this will change,” and prevents the compiler from performing any optimizations based on the stability of that variable. Use this keyword when you read some value outside the control of your code, such as a register in a piece of communication hardware. A volatile variable is always read whenever its value is required, even if it was just read the line before.