Re: Scheduler question in __wake_up_common() - Real Time Apps

From: Steven Rostedt
Date: Mon Feb 28 2005 - 15:47:07 EST


On Mon, 2005-02-28 at 13:30 -0500, Chad N. Tindel wrote:
> I have a question about the implementation in __wake_up_common() that I'm
> hoping someone might know the background on. This function wakes up
> a specified number of tasks for a wait_queue. I'm wondering why it doesn't
> wake up the tasks in priority order, so that for things following wake-one
> semantics high priority tasks get woken up before lower priority tasks.
>
> The only thing I can think of off the top of my head is that it simplifies the
> O(1) implementation, but I'm wondering if maybe there is something else.
>

I believe that it is just simpler the way it is. Otherwise you would
have to sort it each time you add a task to the wait queue, which will
probably just slow everything down with little gain. The higher priority
task will be scheduled before the others that are woken. So I don't see
a problem. As the processes are woken up, the process waking up the
others is protected by spinlocks and interrupts being off. So you don't
have to worry about preemption and one taking over before a higher
priority process gets scheduled. Maybe on on SMP, this might cause a
few extra schedules, but I still don't believe that you gain anything
with a sorted wake up.

As for the exclusive wait. That is merely implementing a FIFO. But extra
work must be done to make sure that you wake up others. I can see your
point that a FIFO ignores priorities, but these are seldom used, except
that it is also used in the implementation of down. But if you are
worried about that, then just use Ingo Molnar's RT patch where the down
implementation not only handles priorities, but also priority inversion.

-- Steve


> Thanks,
>
> Chad
> -

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