> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/4.3bsd/di-yi-bu-fen-gai-lan/2.1.-unix-she-shi-yu-nei-he.md).

# 2.1 UNIX 设施与内核

UNIX 内核提供四项基本设施：进程、文件系统、通信和系统启动。本节概述这四项基本服务分别在哪里描述。

1. 进程构成地址空间中的一条控制线程。创建、终止进程及以其他方式控制进程的机制在第 4 章描述。系统为每个进程多路复用各自独立的虚拟地址空间；这一存储管理在第 5 章讨论。
2. 文件系统与设备的用户接口相似；共同之处在第 6 章讨论。文件系统是一组有名字的文件、按树形层次组织的目录，外加操纵它们的一组操作，见第 7 章的阐述。文件驻留在磁盘等物理介质上，访问它们需要设备驱动，见第 8 章的论述。终端用来访问系统；终端的设备驱动是第 9 章的主题。
3. 传统 UNIX 系统提供的通信机制包括设备 I/O（第 8、9 章）、相关进程之间的单工可靠字节流（见 10.1 节的管道），以及异常事件的通知（见 4.7 节的信号）。4.3BSD 还有一套通用的进程间通信设施，在第 10 章描述。这套设施使用的访问机制不同于文件系统的访问机制，但连接一旦建立，就可以像访问管道一样访问它。此外还有一个通用的联网框架（第 11 章），通常作为进程间通信设施之下的一个层次使用。第 12 章详细描述一种具体的网络实现。
4. 任何真实的操作系统都有运行管理方面的问题，比如如何启动，见第 13 章。

2.4 节到 2.13 节给出与第 4 章到第 13 章对应的引论材料。我们将定义术语、提及基本的系统调用、考察历史发展，最后给出许多重大设计决策的理由。

**内核**

内核（kernel）是系统中提供基本系统设施的那一部分：它创建并管理进程，提供访问文件系统和通信设施的功能。这些功能称为系统调用（system call），在用户进程看来就像其他库子例程一样。系统调用是进程访问这些设施的唯一接口。系统调用机制的细节，以及一些并非由进程执行系统调用直接引发的内核机制，都在第 3 章描述。

用户通常通过一个命令语言解释器与系统交互，它称为 shell，或许还要加上其他用户应用程序。这类程序和 shell 都实现为一组进程。这类程序的细节超出本书范围，本书几乎只集中于内核。

传统操作系统术语中的“内核”指一小块软件核心，只提供实现其他操作系统服务所必需的最少设施。在 Accent \[Fitzgerald & Rashid, 1986]、Tunis \[Ewens et al., 1985] 和 V 内核 \[Cheriton, 1988] 这类当代研究操作系统中，这种功能划分不只是逻辑上的：文件系统和网络协议等服务实现为核心或内核的客户应用程序进程。

4.3BSD 内核没有划分成多个进程。这是 UNIX 最早版本的一项基本设计决策。Ken Thompson 的头两个实现完全没有内存映射，因而在用户空间与内核空间之间也没有硬件强制的区分 \[Ritchie, 1988]。当时实现一个消息传递系统本可以与实际采用的“内核 + 用户进程”模型一样容易。选择后者是为了简单，何况早期内核很小。正是越来越多的设施（如联网）进入内核，才使把这些设施分离到用户进程成为一个诱人的前景——例如 Mach \[Accetta et al., 1986] 就在朝这个方向努力。

以下各节描述 4.3BSD 内核提供的服务，并给出这些服务设计的概貌。后续各章将描述这些服务在 4.3BSD 中的详细设计与实现。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://book.bsdcn.org/4.3bsd/di-yi-bu-fen-gai-lan/2.1.-unix-she-shi-yu-nei-he.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
