Three application scenarios of lock free in linux

Source: Internet
Author: User


Three application scenarios of lock free in linux 1. spin Lock: Spin lock when the Lock operation is blocked, the thread does not immediately suspend itself, but intermittently Spin (self-loop) operation to let the cpu idling to wait for other threads to release lock www.2cto.com 2. the sequential lock Seqlock allows concurrent read/write operations. The principle is to set a counter. When a write operation is performed, add 1 to the counter atom. Before and after the read operation, compare the counter values. If the values are equal, this indicates that no write operation has been performed. If not, the read operation is performed from the beginning. In scenarios with frequent write operations, frequent read operations may be repeated at www.2cto.com 3. during the RCURead-Copy-Update write operation, Copy the current data structure, apply for a new memory space, modify the Copy, Copy the original array content to the new space, and add new values, after the modification, the writer modifies the pointer of the original data structure to point to the new address, and then calls the memory barrier to make the new value visible to other CPUs. Finally, the author firehoo of the original data structure is released.

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.