On 9/14/05, linux lover <caprianking2002@xxxxxxxxx> wrote: > i have basic query > whats the difference between spin_lock, spin_lock_irq and spin_lock_irqsave > similarly corresponding unlock functions. spin_lock ------- this acquires the spinlock without disabling the interrupts on local CPU. This is used when we do not share the critical section with interrupt handlers. spin_lock_irq ------- this acquires the spinlock after disabling the interrupts on local CPU, but do not save the EFLAG register, it simply clears the interrupt bit of EFLAGS. This is used when we share the critical section with Interrupt Service Routine. spin_lock_irqsave ------ this acquires the spinlock after disabling the interrupts on local CPU and also saves the EFLAG register in a local variable, so that we can restore it later on. This again is used when we share critical section with ISR > > if we do seomthing like this : > spin_lock_irqsave(&q1, flag1); > > spin_lock_irqsave(&q2, flag2); > > > spin_unlock_irqrestore(flag1); <------- here its nullifies the irqs saving > for second lock??? > > spin_unlock_irqrestore(flag2); I think you should not do this, Holding another lock while you are already holding the first lock is a bad idea, because because processes waiting for frst lock will keep on waiting just for nothing because you are using the second lock. I think before acquiring the second lock we should release the first lock if possible. Moreover restoring the flags in reverve order is definitely a bad idea, should not do it. -Gaurav -- - Gaurav my blog: http://lkdp.blogspot.com/ -- -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/