Re: Task Switching in Linux

george anzinger (george@mvista.com)
Mon, 11 Jun 2001 15:45:34 -0700


Jaswinder Singh wrote:
>
> In Linux , If we assume that there are only 2 tasks A and B and both are
> equal , this is correct or not :-
>
> TASK A -> schedule -> switch_to -> TASK B -> schedule -> switch_to ->
> schedule -> switch_to -> TASK A.
>
Heck no. TASK A will be run until it either blocks or its time quantum
drops below TASK B's. It does not matter how many times it calls
schedule(), 'cept its a darn waste of time.

Now, it you call sched_yield() your chances are higher, but still no
guarantee. If you get the tasks out of SCHED_OTHER sched_yield() will
do the above (if they have the same priority).

George
-
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/