MPgetlock_edx:
1:
movl (%edx), %eax
movl %eax, %ecx
andl $CPU_FIELD,%ecx
cmpl _cpu_lockid, %ecx
jne 2f
incl %eax
movl %eax, (%edx)
ret
2:
movl $FREE_LOCK, %eax
movl _cpu_lockid, %ecx
incl %ecx
lock
cmpxchg %ecx, (%edx)
jne 1b
GRAB_HWI
ret
- Why upper function can implement a Big kernel Lock (BKL)?
- 'cmpxchg' is atomic? why 'lock' needed before it? (This part is a duplicate of Is x86 CMPXCHG atomic, if so why does it need LOCK?)
- Why not 'movl (%edx), %ecx' directly?