Skip to main content
 首页 » 操作系统

Linux CPU idle学习笔记

2022年07月19日30jillzhang

1. per-cpu的idle线程初始化

(1) boot cpu的idle线程初始化

start_kernel //init/main.c 
    sched_init //kernel/sched/core.c 
        init_idle(current, smp_processor_id()); //当前正在执行的进程将其初始化为此boot CPU的idle线程

(2) 非boot cpu的idle线程初始化

start_kernel //init/main.c 最后调用rest_init 
    rest_init //kernel_thread(kernel_init, NULL, CLONE_FS); 
        kernel_init 
            kernel_init_freeable //init/main.c 
                smp_init //kernel/smp.c 
                    idle_threads_init //kernel\smpboot.c 
                        for_each_possible_cpu(cpu) { 
                            if (cpu != boot_cpu) 
                                idle_init(cpu); /*为非boot cpu初始化idle线程*/ 
                        }

本文参考链接:https://www.cnblogs.com/hellokitty2/p/14953617.html