内核源码--------boot_cpu_init();
来源:互联网 发布:华美卷皮最新源码 编辑:程序博客网 时间:2024/06/05 07:59
继续回到start_kernel,来到函数boot_cpu_init();定位到该函数
static void __init boot_cpu_init(void)
{
int cpu = smp_processor_id();
/* Mark the boot cpu "present", "online" etc for SMP and UP case */
set_cpu_online(cpu, true);
set_cpu_active(cpu, true);
set_cpu_present(cpu, true);
set_cpu_possible(cpu, true);
}
首先来看函数smp_processor_id(),定位到该函数
#ifdef CONFIG_DEBUG_PREEMPT
extern unsigned int debug_smp_processor_id(void);
# define smp_processor_id() debug_smp_processor_id()
#else
# define smp_processor_id() raw_smp_processor_id()
#endif
由于没有定义宏CONFIG_DEBUG_PREEMPT,所以最终调用的就是 raw_smp_processor_id(),定位到该函数
#define raw_smp_processor_id() (current_thread_info()->cpu)
可以看得出该函数的值是current_thread_info()结构体的cpu的值,定位到current_thread_info()
static inline struct thread_info *current_thread_info(void)
{
struct thread_info *ti;
__asm__ __volatile__ ("and.d $sp, %0" : "=r" (ti) : "0" (~8191UL));
return ti;
}
该函数中,汇编部分不是太明白,细节的后面在研究,ti是hread_info类型的结构体,该结构体如下
struct thread_info {
struct task_struct *task;/* main task structure */
struct exec_domain *exec_domain;/* execution domain */
unsigned long flags;/* thread_info flags (see TIF_*) */
mm_segment_t addr_limit;/* user-level address space limit */
__u32 cpu; /* current CPU */
int preempt_count;/* 0=premptable, <0=BUG; will also serve as bh-counter */
struct restart_block restart_block;
};
这样函数smp_processor_id()就得到了当前CPU的ID,下面的几个函数是设置cpu相关的变量的值,不再细细研究了。
- 内核源码--------boot_cpu_init();
- 源码内核
- start_kernel——boot_cpu_init及PER_CPU
- 看Linux内核源码
- linux 内核源码结构
- linux内核源码组织
- 内核源码树编译
- 内核源码编排
- 内核源码kfifo分析
- fedora 安装内核源码
- Fedora安装内核源码
- ubuntu安装内核源码
- linux内核源码阅读
- 构造内核源码树
- Linux内核源码
- 内核源码目录结构
- 安装内核源码树
- 内核源码API
- android GPS 冷启动
- tomcat配置多个端口号,多个应用
- 欢迎使用CSDN-markdown编辑器
- 将数据储存到SharedPreferences
- Mac10.12下Eclipse4.6+Maven3.5+Tomcat8.5+JDK1.8开发环境的搭建
- 内核源码--------boot_cpu_init();
- iOS开发抓包工具之Charles使用
- SQL介绍
- MyBatis对象关系映射--- 多对一
- Word2vec 原理公式推到和代码实现
- java.util.Date和java.sql.Date的区别及应用
- C++对象的内存分布和虚函数表
- Ubuntu16.04 Jupyter安装(Ipython Notebook安装)
- androidStudio打包apk混淆配置