Why can not processes switch in atomic context?
From: 卜弋天 <hidden>
Date: 2012-07-05 14:17:35
Date: Wed, 4 Jul 2012 08:12:25 -0700 Subject: Re: Why can not processes switch in atomic context? From: dhylands at gmail.com To: buyit at live.cn CC: mobile.parmenides at gmail.com; kernelnewbies at kernelnewbies.org Hi, On Wed, Jul 4, 2012 at 3:44 AM, ?? ? [off-list ref] wrote:quoted
? 2012-7-3?22:26?"Parmenides" [off-list ref] ???...snip...quoted
quoted
1. For the spinlock case, it is easy to get if preemption is allowed in critical section, the purpose of protection provided by spinlock can not be achieved readily.i think disable preemption in spinlock is not for safe, it is For efficiency. Spinlock should exit as soon as possible. If tank1 get spinlock and goto sleep for 100 seconds before Release spinlock, task2 which requests the same spinlock Should wait for 100 seconds, for this example, mutex should be used instead of spinlock.Unless, of course, the interrupt that fired tried to acquire the spinlock it preempted, in which case you would have deadlock, even on an SMP system, if the same processor happened to be used for both.
yes, i think you are right, suppose task1 use spin_lock_irqsave() to get a spinlock, then call schedule() to sleep for a long time, the interrupt on this cpu core will be enabled by kernel, and if there is an interrupt triggered on the same cpu and get the same spinlock, deadlock will happen. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120705/0072093f/attachment.html