Spinlock,中文译名为“自旋锁”。是专为防止多处理器并发而引入的一种锁.
1.Spinlock初始化
如: spin_lock_init(&logbuf_lock),
spin_lock_init(&logbuf_lock);等价于
ogbuf_lock=(spinlock_t){.raw_lock={0},…..};
其实就是把raw_lock成员初始化为0
2.加锁
#definespin_lock(lock) _spin_lock(lock)
->
void__lockfunc _spin_lock(spinlock_t *lock)
{
preempt_disable();// 空函数
spin_acquire(&lock->dep_map,0, 0, _RET_IP_);
_raw_spin_lock(lock);
}