Volatile and non-cacheable

Source: Internet
Author: User
Tags ranges volatile

In some applications, some specific addresses could need to is read from their physical locations each time they is Accesse D (e.g., a status register within FPGA).

The L2 controller offers registers that control whether certain ranges of memory is cacheable, and whether one or more re Questors is actually permitted to access these ranges. The registers is referred to as MARs (memory attribute registers).
note-using the volatile keyword in the C language does not protect a variable from being cached. If an application uses a memory location periodically updated by external hardware, in order to protect the operation in C code Follow these-steps:
Use the volatile keyword to prevent, the code generation tools from incorrectly optimizing the variable.
You must program the MAR register of the range containing the variable to prevent caching.


The role of the volatile keyword in C code, in addition to preventing the CPU from directly using the register and the cache variables, only the global symbols that may be modified in other modules, only when writing concurrent programs, it is possible to use the need for volatile.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.