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

What is a pointer in c plus plus?

702


What does the function toupper() do?

669


What is the right type to use for boolean values in c?

597


What is abstract data structure in c?

537


How can you tell whether two strings are the same?

842






What are the types of c language?

566


what is recursion in C

622


what is the basis for selection of arrays or pointers as data structure in a program

3797


What is a struct c#?

609


Why do we use return in c?

575


difference between Low, Middle, High Level languages in c ?

1640


How can I swap two values without using a temporary?

627


Why is #define used?

802


List the difference between a While & Do While loops?

645


Explain About fork()?

658