1

The scheduler entry in Linux starts with executing schedule() which then calls the __schedule() function. It is defined as :

asmlinkage __visible void __sched schedule(void)
{
    struct task_struct *tsk = current;

    sched_submit_work(tsk);
    do {
        preempt_disable();
        __schedule(false);
        sched_preempt_enable_no_resched();
    } while (need_resched());
}

My question is - why is there a need to disable preemption in the scheduler code when no other task could possibly call the schedule() function and thus preemption should be automatically disabled until the next task is scheduled. Am I missing something basic here?

4

0 回答 0