blob: e2e090738f562ce120b79881a7b55bdb89018137 [file] [log] [blame]
<html devsite><head>
<title>内核</title>
<meta name="project_path" value="/_project.yaml"/>
<meta name="book_path" value="/_book.yaml"/>
</head>
<body>
<!--
Copyright 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<p>Linux 内核是几乎所有的 Android 设备上极其重要的软件组成部分。本部分介绍了 Linux 内核开发和版本模型(如下)、<a href="/devices/architecture/kernel/releases.html">稳定的长期支持 (LTS) 内核</a>(包括所有 Android 设备都应使用稳定版本而非择优挑选补丁程序的原因)、内核<a href="/devices/architecture/kernel/config.html">配置</a><a href="/devices/architecture/kernel/hardening.html">加固</a><a href="/devices/architecture/kernel/reqs-interfaces.html">接口</a><a href="/devices/architecture/kernel/modular-kernels.html">模块化内核</a>要求(在 Android O 中推出)、内核<a href="/devices/architecture/kernel/lldb-debug.html">调试</a><a href="/devices/architecture/kernel/network_tests.html">网络测试</a>以及 <a href="/devices/architecture/kernel/squashfs.html">SquashFS</a></p>
<h2 id="linux-kernel-development">Linux 内核开发</h2>
<p>
Linux 内核是迄今为止最大的协同软件项目。在 2016 年,超过 450 家不同公司的 4000 多名开发者对该项目做出了贡献。该项目共有 6 个版本,每个版本都包含 12000 到 16000 项不同的更改。在 2016 年底,Linux 内核的规模刚好超过 56000 个文件,其中包括 2200 万行代码、编译脚本和文档(内核版本 4.9)。(要查看完整的 Linux 开发统计信息,请参阅 <a href="https://kernelnewbies.org/DevelopmentStatistics" class="external">https://kernelnewbies.org/DevelopmentStatistics</a>。)
</p>
<p>
虽然 Linux 内核包含其支持的所有不同芯片架构和硬件驱动程序的代码,但各个系统仅运行一小部分代码库。一台普通的笔记本电脑需要使用来自 5000 个文件的大约 200 万行内核代码才能正常运行;而 Pixel 手机需要使用来自 6000 个文件的 320 万行内核代码才能正常运行(因为 SoC 的复杂性有所增加)。
</p>
<h2 id="linux-kernel-releases">Linux 内核版本</h2>
<p>Linux 内核使用的版本模型与标准 AOSP 版本大不相同。随着 2.6 内核在 2003 年 12 月发布,内核开发者社区从之前具有单独开发和稳定内核分支的模型迁移到“仅限稳定”的分支模型。<em></em>在此模型中,每 2-3 个月发布一次新版本,内核开发者社区声明该版本“稳定”,并建议所有用户运行该版本。<em></em>开发模型出现这种变化的原因在于:2.6 版本内核之前的版本周期非常长(将近 3 年),且同时维护两个不同的代码库分支难度很高。</p>
<p>内核版本的编号从 2.6.x 开始,其中 x 是个数字,会在每次发布新版本时递增(除了表示此版本比上一内核版本更新之外,该数字的值不具有任何意义)。自那时起,内核版本现在已发展到 4.x,其中发生了 2 次重大版本变更。维护人员采用这些版本号只是为了避免更高的次要版本号令用户感到困惑。</p>
</body></html>