I am writing a driver,it has a data structure which is modified in both interrupt context and user context.My current design is some thing like this: struct shared_data; interrupt_context{ spin_lock_irqsave(&xxx_lock,flags); ....modify shared_data.... spin_unlock_irqrestore(&xxx_lock, flags); } user_context{ spin_lock_irqsave(&xxx_lock,flags); ....modify shared_data.... spin_unlock_irqrestore(&xxx_lock, flags); } Now when user_context has the ability to sleep,i am wondering if there is a way to safely sleep in the user context while waiting for the spinlock to be released by the interrupt_context?Something like this interrupt_context{ spin_lock_irqsave(&xxx_lock,flags); ....modify shared_data.... spin_unlock_irqrestore(&xxx_lock, flags); wake_up_interruptible(&wait_queue); } user_context{ if(wait_event_interruptible(&wait_queue,\ spin_trylock_irqsave(&xxx_lock,flags)) return -ERESTARTSYS; ....modify shared_data.... spin_unlock_irqrestore(&xxx_lock, flags); } Here the function spin_trylock_irqsave() will try to grab the spinlock if it succeeds it returns true and behaves just like spin_lock_irqsave(),if it is unable to grab the spinlock,the function returns false and the process is put to sleep. This way i dont waste cpu cycles,by spinning uselessly.Is this possible and will it be more efficient than the previous case? -- Anubhav Rakshit -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ