On 07 Oct 2009, at 7:47 AM, er krishna wrote: Rajat San, There are a few variants of the spin lock APIs. See the link which various people have posted for details: The most basic spin_lock() does not disable scheduling or interrupts etc., so must be avoided for synchronization between a syscall and an interrupt context otherwise you will get deadlock. spin_lock_irqsave() disables all pre-emptive scheduling and interrupts AFAIK, so it would be safe. I think it is generally preferable to avoid using spin_lock_irqsave() if possible by deferring your interrupt work to a tasklet (in which you can use spin_lock_bh to sync to your syscall) or a workqueue (in which you can use a semaphore to sync to your syscall). Even better would be to use lockless algorithms or data structures if possible. In general, if you must use a spinlock, try to keep it limited to a very small piece of code to reduce lock contention. Also, enable kernel debugging and specifically the options about lock checking, these can help a great deal to debug issues. I hope the aforementioned information is correct and doesn't lead you astray... |