Re: Task Switching in Linux

george anzinger
2001-06-11T22:47:58Z

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