1 ARCH_SPIN_LOCK /UNLOCK
Take armv7 code for example, its codes is much clear and easy tounderstand
Codes
static inline void arch_spin_lock(arch_spinlock_t *lock)
{
unsigned long tmp;
u32 newval;
arch_spinlock_tlockval;
__asm__ __volatile__(
"1: ldrex %0, [%3]\n" //lockval= lock->slock
" add %1, %0, %4\n" //newval = (lockval->next+1) | lockval->owner
" strex %2, %1, [%3]\n" //lock->slock =newval
" teq %2, #0\n"
" bne 1b" //if status is not 0 means storehasn't took place
: "=&r"(lockval), "=&r" (ne