how the compiler treats any volatile variable?Explain with
example.

Answer Posted / daniboy

A volatile variable is one whose VALUE CAN CHANGE
UNEXPECTEDLY. Consequently, the compiler can make NO
ASSUMPTIONS about the value of the variable. In
particular, the optimizer must be careful to RELOAD the
variable every time it is used instead of holding a copy in
a register.
Examples of volatile variables are:

(a) Hardware registers in peripherals (e.g., status
registers)
(b) Non-stack variables referenced within an interrupt
service routine.
(c) Variables shared by multiple tasks in a multi-
threaded application.

Source: 10 Best Questions to would-be Embedded Programmers -
By Nigel Johns

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does free() know explain how much memory to release?

621


Why does the call char scanf work?

620


what is event driven software and what is procedural driven software?

2016


What is a nested formula?

605


Create a simple code fragment that will swap the values of two variables num1 and num2.

813






Once I have used freopen, how can I get the original stdout (or stdin) back?

628


What is .obj file in c?

648


What is difference between scanf and gets?

612


What is the advantage of using #define to declare a constant?

621


Explain what is the stack?

636


Write a program to print fibonacci series using recursion?

585


What is difference between far and near pointers?

612


What is c programing language?

615


write a program to rearrange the array such way that all even elements should come first and next come odd

1762


What is meant by type casting?

629