Thread (12 messages) 12 messages, 7 authors, 2012-07-05

Why can not processes switch in atomic context?

From: Dave Hylands <hidden>
Date: 2012-07-04 15:12:25

Hi,

On Wed, Jul 4, 2012 at 3:44 AM, ?? ? [off-list ref] wrote:

? 2012-7-3?22:26?"Parmenides" [off-list ref] ???
...snip...
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.
quoted
2. For the interrupt context case, I think when processing interrupt,
kernel can be preempted in principle. But, this really increases the
interrupt processing time which further cause longer response time and
data missing in device. Except that, is there any other reasons?
You are right, kernel can schedule in interrupt context, but that will delay the completion of interrupt, which does not make sense, so kernel will not do like this.
Note! Kernel can, but should not schedule in interrupt context.
Scheduling in an interrupt can hang the system. Lets suppose that A
acquires a resource, disabled interrupts and calls schedule. Then B
gets scheduled and wants the resource that A is holding so it blocks.
But since interrupts were disabled, the timer tick will never fire and
you're back into a deadlock situation again.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help