Implementation of sub-operation atomic in ARM architecture

Source: Internet
Author: User

The atomic operation of integers, for the atomic_t type, has always been mentioned in the book that the CPU architecture itself supports simple atomic operations, or provides the function of locking the memory bus, you can prevent data access during the operation.

Today, we suddenly thought that the ARM architecture itself does not provide the lock memory bus function, and there are no commands similar to atomic operations. How can we implement atomic operations? Have a lookCodeOriginally, interruption is disabled. Because the ARM architecture does not support the SMP architecture, disabling the interruption eliminates the possibility of code concurrency, thus achieving atomic operations.

In addition, the architecture above armv6 uses ldrex and strex commands to achieve exclusive access to a memory address, thus avoiding the operation prohibition of interruption. (From the instruction explanation, I guess this is true, but I don't know much about it)

• Ldrex {<cond >}< RD>, [<rn>]
This performs a load, then sets a monitor to "watch" the address
• Strex {<cond >}< RD >,< Rm>, [<rn>]
This performs a store and returns "success" in RD if no intervening access
Detected by the monitor.

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.