内核源码--------smp_setup_processor_id()

回到start_kernel函数,进入到smp_setup_processor_id()中,

void __init smp_setup_processor_id(void)

{
int i;
u32 mpidr = is_smp() ? read_cpuid_mpidr() & MPIDR_HWID_BITMASK : 0;
u32 cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);


cpu_logical_map(0) = cpu;
for (i = 1; i < nr_cpu_ids; ++i)
cpu_logical_map(i) = i == cpu ? 0 : i;


/*
* clear __my_cpu_offset on boot CPU to avoid hang caused by
* using percpu variable early, for example, lockdep will
* access percpu variable inside lock_release
*/
set_my_cpu_offset(0);


pr_info("Booting Linux on physical CPU 0x%x\n", mpidr);

}

smp指的是对称多处理模型,对应的是非一致存储访问结构和海量并行处理结构,指的是多个之间是平等的,共享资源,这样就会导致抢占资源的现象。

你可能感兴趣的:(内核源码阅读笔记)