Structure typedef struct analysis of rwlock {volatile unsigned int lock;} rwlock_t; rwlock_t tasklist_lock __attribute __ ((__ aligned __ ((1 << ((5)))), __ section __ ( ". Data.cacheline_aligned"))) = (rwlock_t) { 0x01000000};; 0x01000000 (RW_LOCK_UNLOCKED) is a bias value read_lock (& Tasklist_lock); addressed as lock; Subl $ 1, tasklist_lock minus 1 JS 2F If the negative indicator has been written by Write_lock 1: .section .text.lock, "AX "2: pushl% eax leal tasklist_lock,% eax take tasklist_lock address call __read_lock_failed popl% eax jmp 1b arrested lock succeeded .previous; semaphore.c__read_lock_failed: lock; value incl (% eax) recovery tasklist_lock of 1: cmpl $ 1, ( % eax) js 1b if tasklist_lock less than 1 indicates write_unlock not been unlocked lock; decl (% eax) ready to crawl again tasklist_lock js __read_lock_failed it is a write_lock locked again cycle ret read_unlock (& tasklist_lock); unravel for the lock; INCL TASKLIST_LOCK WRITE_LOCK_IRQ (& Tasklist_lock); Credited to CLI LOCK; Subl $ 0x01000000, (Tasklist_lock) subtracts the offset value of TaskList_lock If it is not 0, it will be locked by read_lock () or write_lock () 1: .section .Text.lock, "AX" 2: Pushl% EAX LEAL TASKLIST_LOCK,% EAX CALL __WRITE_LOCK_FAILED POPL% EAX JM P 1b.Previous; semaphore.c__write_lock_failed: Lock; AddL $ 0x01000000, (% EAX) Restore Tasklist_lock Value 1: CMPL $ 0x01000000, (% EAX) JNE 1B Waiting for Unlock Lock; SUBL $ 0x01000000, (% EAX) again capture JNZ again __write_lock_failed If it is locked, loop RET WRITE_UNLOCK_IRQ (& Tasklist_lock) again; Credited to: LOCK; AddL $ 0x01000000, Tasklist_lock Recovery Offset Diagram STI