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.