Linux Kernel synchronization self-study report

Source: Internet
Author: User

The kernel synchronizes data instead of logic ).

Interrupt handlingProgramSecurity that can avoid concurrent accessCodeThe security code is called the security code of interruption, and the security code that can avoid concurrent access on Symmetric Multi-processing machines is called the SMP Security Code (SMP-safe ), the security code that can avoid concurrent access during kernel preemption is called preempt-safte ).

1. Atomic operations can only be performed on integers or bits. The atomic_t type is used (only 24 bits are allowed, because a lock is embedded in the lower eight bits of the int type in the iSCSI system ).

2. spin lock can only be held by one executable thread at most. A competing spin lock allows the thread requesting it to spin when waiting for the lock to be re-available (occupying CPU waiting ). So the spin lock should not be occupied for a long time. It is generally applicable to SMP. On a single processor machine, the spin lock is not added during compilation. It is used only as a switch to set whether the kernel preemption mechanism is enabled. The spin lock cannot be recursive (when the spin lock is used in the interrupt processing program, you must first disable local interruption before obtaining the lock, because the interrupt processing program will interrupt the kernel code that is holding the lock ).

3. semaphore. Synchronous Mechanism for sleep. Because of sleep, the use of this lock may lead to the consumption of process switching. Semaphores are called count semaphores (counting semaphone). The number of semaphores can be greater than 1. semaphores and spin locks cannot be used at the same time.

Order and barrier to ensure the sequential execution of programs.

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.