On Fri, Feb 12, 2010 at 11:21 PM, Vipul Jain <vipulsj@xxxxxxxxx> wrote: > Hello All, > > I am trying to understand the what's the difference between spinlock and > spinlock_bh. I was wondering if someone could please help me in > understanding it and when to use spinlock_bh over spinlock. > > Thanks & Regards, > Vipul. > Hi Vipul, spin_lock() function just tries to acquire the lock, but spin_lock_bh() will disable softirqs also. e.g. if you want to protect some data which is shared between some user context and a timer(or softirq or tasklet), you can not use just spin_lock(). Because your user context can get interrupted by timer thread which will try to acquire the lock which is already locked by the user context. Please refer to the "Unreliable Guide To Locking", http://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/x137.html http://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/c214.html#MINIMUM-LOCK-REQIREMENTS Hope this helps. -Vinit -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ