Owais Ekteelat
Owais Ekteelat

Reputation: 21

change while(1) loop to busy wait in linux kernel

void cpu_idle (void)
{
    /* endless idle loop with no priority at all */

    while (1) {
        void (*idle)(void) = pm_idle;
        if (!idle)
            idle = default_idle;
        if (!current->need_resched)
            idle();
        schedule();
        check_pgt_cache();
    }
}

this code existed in : "arch/i386/kernel/process.c" related to linux 2.4.18-14

this code is responsable of the ( cpu idle loop ).

the question is : can I change the while(1) loop with bust wait ?

Upvotes: 0

Views: 1246

Answers (1)

bodangly
bodangly

Reputation: 2624

The loop here properly schedules processes so the system continues to run properly. Switching to a pure busy wait would lock up the system when the cpu goes idle, meaning other processes would cease to be scheduled. You definitely do not want that.

Upvotes: 1

Related Questions