lkml.org 
[lkml]   [2002]   [Sep]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: question on spinlocks
From
Date
On Sun, 2002-09-01 at 17:53, Thunder from the hill wrote:

> If it was his least problem! He'll run straight into a "schedule w/IRQs
> disabled" bug.

No, the "schedule with irqs disabled" message is on involuntary
reschedule (e.g. kernel preemption) when interrupts are disabled.

It "safe" (maybe not sane) to call schedule() with interrupts disabled -
some system calls and scheduler code do it since interrupts will be
unconditionally enabled when rescheduled or upon returning to
user-space. E.g., see sys_sched_yield().

The actual problem with the above is that when schedule() returns,
interrupts will be on and that is probably not the intention of the
author. What Oliver probably wants to do is:

spin_lock_irq(&lck);
...
spin_unlock(&lck);
schedule();
spin_lock_irq(&lck);
...
spin_unlock_irq(&lck);

The first unlock not having the irq-enable is an optimization as
described above. Also note I did not use irqsave... if there is a
chance interrupts were previously disabled and you have who-knows-what
sort of call-chain behind you, it is probably not safe to go calling
schedule() and reenabling interrupts anyhow.

Robert Love

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:28    [from the cache]
©2003-2011 Jasper Spaans