# System Initialization

## CPU

* 计算单元
* 数据单元
  * 缓存
  * 寄存器组
* 控制单元
  * 指令起始地址寄存器（CS）：
  * 数据起始地址寄存器（DS）：
  * 指令指针寄存器（IP）：下一条指令在内存中的地址
  * 指令寄存器：代码段

总线：

* 地址总线：位数决定了能访问到的地址范围
* 数据总线：位数决定了一次能拿多少数据

x86：

* 总线位宽：16
* 地址位：20

Linux 启动过程中有三个特殊进程：

* 0 号 idle 进程，初始化 1、2 号进程后演变为空闲任务，CPU 没有其它任务运行时就运行它。
* 1 号 init 进程，通常为 systemd 进程，在用户态运行，用于管理其它用户态进程。
* 2 号 kthreadd 进程，内核态运行，用于管理所有内核态线程。

常见的内核线程有：

* ksoftirqd：处理软中断，每个 CPU 有一个。
* kswapd0：用于内存回收。
* kworker：执行内核工作队列。分为绑定 CPU 和未绑定 CPU 两类。
* migration：负载均衡过程中，把进程迁移到 CPU，每个 CPU 有一个。
* jdb2/sda1-8：为文件系统提供日志功能，保证数据完整性。每个使用 ext4 的磁盘，都有一个 jdb2 线程。
* pdflush：将内存中的脏页写入磁盘。新版本已合入 kworker 中。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yunzhao.gitbook.io/notes/computer-science/linux/system-initialization.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
