参照元†
返り値†
プリエンプション有効の場合†
/*
* These are the BKL spinlocks - we try to be polite about preemption.
* If SMP is not on (ie UP preemption), this all goes away because the
* do_raw_spin_trylock() will always succeed.
*/
#ifdef CONFIG_PREEMPT
static inline void __lock_kernel(void)
{
preempt_disable();
if (unlikely(!do_raw_spin_trylock(&kernel_flag))) {
/*
* If preemption was disabled even before this
* was called, there's nothing we can be polite
* about - just spin.
*/
if (preempt_count() > 1) {
do_raw_spin_lock(&kernel_flag);
return;
}
/*
* Otherwise, let's wait for the kernel lock
* with preemption enabled..
*/
do {
preempt_enable();
while (raw_spin_is_locked(&kernel_flag))
cpu_relax();
preempt_disable();
} while (!do_raw_spin_trylock(&kernel_flag));
}
}
プリエンプション無効の場合†
#else
/*
* Non-preemption case - just get the spinlock
*/
static inline void __lock_kernel(void)
{
do_raw_spin_lock(&kernel_flag);
}
#endif
コメント†