Re: scheduling with spinlocks held ?

From: Robert Love (rml@tech9.net)
Date: Tue Jul 01 2003 - 19:19:10 EST


On Tue, 2003-07-01 at 17:10, Muthian Sivathanu wrote:

> Is it safe to assume that the kernel will not preempt
> a process when its holding a spinlock ? I know most
> parts of the code make sure they dont yield the cpu
> when they are holding spinlocks, but I was just
> curious if there is any place that does that.

Correct.

> Basically, the context is, I need to change the
> scheduler a bit to implement "perfect nice -19"
> semantics, i.e. give cpu to nice 19 process only if no
> other normal process is ready to run. I am wondering
> if there is a possibility of priority inversion if the
> nice-d process happens to yield the cpu and then never
> get scheduled because a normal process is spinning on
> the lock.

You will hit priority inversion... not with spinlocks but with
semaphores (and possibly more subtle issues).

The only safe way to do this safely is to boost the task's priority out
of the "idle" class when the task is inside the kernel.

It is nontrivial to juggle user vs. kernel returns such as that. Google
for Ingo Molnar's SCHED_BATCH addition to the O(1) scheduler.

        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/



This archive was generated by hypermail 2b29 : Mon Jul 07 2003 - 22:00:14 EST