why does the 'break_lock' field of spinlock exist for preemptive kernel?

Parmenides mobile.parmenides at gmail.com
Sun Oct 16 06:54:56 EDT 2011


Hi,

    I am reading the source code of spinlock and have a question about
it. The spinlock is defined as:

typedef struct {
     volatile unsigned int slock;
#ifdef CONFIG_PREEMPT
     unsigned int break_lock;
#endif
} spinlock_t;

When 'break_lock' is one, it indicates that there are other tasks
waiting the spinlock. If so, these tasks should be running on other
CPUs. In other words, there are definitely no other tasks waiting the
lock, which are on the same CPU on which the spinlock owner is runing,
because the owner has disabled the kernel preemption. That is, there
are no other local tasks which can set 'break_lock' to 1. Therefore, I
think whether or not 'break_lock' is defined has nothing to do with
CONFIG_PREEMPT. May be a misunderstanding. Any explanation?



More information about the Kernelnewbies mailing list