What is the use of volatile keyword?

test
test

Posted On: Apr 11, 2020

 

The volatile keyword is used to check the compiler from utilizing any optimizations on items that can improve in actions that may not be decided by the compiler. Objects listed as volatile are excluded from optimization as their rates can be modified by cryptogram outside the range of prevailing code at every time. A volatile keyword is utilized to change the rate of a variable by diverse threads. It is additionally used to create classes thread-safe. It signifies that many threads may utilize a process and situation of the groups at the identical time sans any difficulty. The volatile keyword may be utilized each with fundamental types or items.

The volatile keyword produces no reserve in the rate of the variable and constantly reads the variable from the principal consciousness. The volatile keyword may not be utilized with groups or programs. Nevertheless, it is managed with variables. It also ensures visibility and systemization. It stops the compiler of the reordering of the cryptogram.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Embedded Systems Interview Questions

    Explian what is embedded system?

    An embedded system is a hardware system attached with software that is designed to perform a dedicated function or a specific task, either as an independent system or as a part of a large system....

    Embedded Systems Interview Questions

    What are major components of embedded system?

    There are three major components of an embedded system i.e. hardware, software, and operating system. The sub-division of these components are Processor, Memory, Timers counters, Communication ports, ...

    Embedded Systems Interview Questions

    What is difference between thread and process?

    Process means a program that is under execution that runs in separate memory spaces whereas a thread means a segment of a process that shares information like data segment, code segment, files, etc. w...