Queuing spin lock for Linux kernel

Source: Internet
Author: User
Article title: queuing spin lock for Linux kernel. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

The FIFO Ticket Spinlock is a new type of spin lock introduced in Linux kernel 2.6.25. it solves the "fairness" problem caused by disorderly competition of traditional spin locks. This article describes in detail the design principles and implementation of queuing spin locks, and compares them with similar technologies used in Windows. Finally, we discuss some possible ideas for extending the queuing spin lock.

Introduction

The spin lock is an underlying synchronization mechanism widely used in Linux kernel. A spin lock is a special lock that works in a multi-processor environment. in a single processing environment, the spin lock operation is replaced with a null operation. When a kernel execution thread on a processor applies for a spin lock, if the lock is available, the lock is obtained, and then the critical zone operation is executed to release the lock. if the lock is occupied, the thread is not going to sleep, but is waiting for the lock. once the lock is released, the first thread that perceives this information will get the lock.

For a long time, people have always focused on the security and efficiency of spin locks, while ignoring the "fairness" of spin locks. The traditional spin lock is essentially represented by an integer. The value of 1 indicates that the lock is not occupied. Due to this nature of disorderly competition, the execution thread cannot guarantee when the lock can be obtained. some threads may have to wait for a long time. With the increasing number of computer processors, this "unfair" problem will become increasingly serious.

The queuing spin lock (FIFO Ticket Spinlock) is a new type of spin lock introduced in Linux kernel 2.6.25, it solves the "unfair" problem of the traditional spin lock by saving the sequential information of the lock applied by the execution thread. The code for queuing spin locks is implemented by Linux kernel developer Nick Piggin. Currently, it is only for x86 architecture (including IA32 and x86_64). I believe it will soon be transplanted to other platforms.

[1] [2] [3] [4] [5] Next page

Related Article

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.