On 6/7/07, keshetti85-linux@xxxxxxxxxxx <keshetti85-linux@xxxxxxxxxxx> wrote:
Hi list, Can anybody tell me what is the intended use of the spin_lock_irqsave? The only extra thing spn_lock_irqsave does when compared to spin_lock_irq is, it saves the current context(?) in some variable. But why is it required at all?
Mahesh.
Hi, The previous state of the irqs is retained by spin_lock_irqsave/restore. The reason is if you have 2 consecutive calls to spin_lock_irq() (you don't know they're consecutive because they can be called from different functions) it would be like: spin_lock_irq() <-- Irqs disabled spin_lock_irq() <-- Irqs disabled spin_unlock_irq() <-- Error! irqs enabled spin_unlock_irq() <-- Irqs were meant to be enabled here. Whereas: spin_lock_irq() <-- Irqs disabled spin_lock_irqsave() <-- Irqs disabled, save disabled state. spin_unlock_irqrestore() <-- Retain state. Irqs still disabled. spin_unlock_irq() <-- Irqs enabled. Thanks, Bahadir -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ