Answer Posted / vishal
What is the significance of volatile keyword?
Volatile keyword is used to inform the compiler not to predict/assume/believe/presume the value of the particular variable which has been declared as volatile.
Why/When do we need volatile ?
In following case we need to use volatile variable.
Memory-mapped peripheral registers
Global variables modified by an interrupt service routine
Global variables within a multi-threaded application
If we do not use volatile qualifier the following problems may arise:
Code that works fine-until you turn optimization on
Code that works fine-as long as interrupts are disabled
Flaky hardware drivers
Tasks that work fine in isolation-yet crash when another task is enabled
Source: http://www.firmcodes.com/volatile-keyword-in-c-and-embedded-system/
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is a pragma?
What are the different data types in C?
What is difference between array and structure in c?
How can I determine whether a machines byte order is big-endian or little-endian?
What are void pointers in c?
Why is c called a structured programming language?
How is actual parameter different from the formal parameter?
How do you print an address?
What is difference between union All statement and Union?
What is pre-emptive data structure and explain it with example?
What is the difference between abs() and fabs() functions?
What is a #include preprocessor?
Are enumerations really portable?
Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.
What is the purpose of sprintf() function?