# Zephyr（操作系统）

**Zephyr** 是一款面向资源受限嵌入式设备的开源实时操作系统（RTOS），由 [Linux 基金会](https://www.edgepedia.org/zh/linux-foundation)（Linux Foundation）作为协作项目托管，在 [Apache License](https://www.edgepedia.org/zh/apache-license) 2.0 下分发<sup>[1](https://www.zephyrproject.org/learn-about/)</sup><sup> • </sup><sup>[2](https://www.intel.com/content/www/us/en/developer/articles/community/zephyr-story-how-became-self-sustaining-ecosystem.html)</sup>。其目标硬件涵盖从简单的环境传感器和 LED 可穿戴设备到智能手表和物联网无线应用，其设计使应用程序仅纳入所需的内核功能，资源数量和大小在编译时固定<sup>[3](https://docs.zephyrproject.org/latest/introduction)</sup>。Zephyr 项目称该软件已部署在超过一千万台设备的产品中，支持超过一千种开发板<sup>[4](https://www.zephyrproject.org/)</sup>。

| 关键事实 | 详情 |
|---|---|
| 治理 | 由 Linux 基金会托管的开源协作项目；Apache 2.0 许可证，商业和非商业用途均免费<sup>[1](https://www.zephyrproject.org/learn-about/)</sup> |
| 起源 | 2014 年源自风河（Wind River）基于 VxMicro 的代码；2016 年 2 月作为 Linux 基金会项目公开启动，创始成员包括英特尔（Intel）、风河、新思科技（Synopsys）和恩智浦（NXP）<sup>[2](https://www.intel.com/content/www/us/en/developer/articles/community/zephyr-story-how-became-self-sustaining-ecosystem.html)</sup><sup> • </sup><sup>[5](https://www.acnnewswire.com/press-release/japanese/28179/linux-foundation%E3%80%81%E3%83%A2%E3%83%8E%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%BF%E3%83%BC%E3%83%8D%E3%83%83%E3%83%88%EF%BC%88iot%EF%BC%89%E5%90%91%E3%81%91%E3%83%AA%E3%82%A2%E3%83%AB%E3%82%BF%E3%82%A4%E3%83%A0%E3%82%AA%E3%83%9A%E3%83%AC%E3%83%BC%E3%83%86%E3%82%A3%E3%83%B3%E3%82%B0%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0%E6%A7%8B%E7%AF%89%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%82%92%E7%99%BA%E8%A1%A8)</sup> |
| 当前版本 | Zephyr 4.4.0，发布于 2026 年 4 月 14 日，为半年发布节奏下的首个版本；下一版本 4.5 计划于 2026 年 10 月发布<sup>[6](https://docs.zephyrproject.org/latest/releases/index.html)</sup><sup> • </sup><sup>[7](https://www.zephyrproject.org/zephyr-rtos-4-4-now-available-wireguard-wi-fi-direct-openrisc-and-more/)</sup> |
| 长期支持 | Zephyr 3.7.0（LTS3），发布于 2024 年 7 月 26 日，支持至 2029 年 7 月 27 日<sup>[6](https://docs.zephyrproject.org/latest/releases/index.html)</sup> |
| 架构 | ARM、RISC-V、x86、Xtensa、ARC、MIPS、SPARC，自 4.4 起支持 OpenRISC（32 位）<sup>[7](https://www.zephyrproject.org/zephyr-rtos-4-4-now-available-wireguard-wi-fi-direct-openrisc-and-more/)</sup> |
| 安全设计 | 单体式：内核与应用程序编译为单一静态二进制文件；系统调用即函数调用，无上下文切换；密码学通过基于 Mbed TLS 的 PSA Crypto 提供<sup>[8](https://docs.zephyrproject.org/latest/security/security-overview.html)</sup> |
| 规模 | 用于部署在超过一千万台设备的产品中；支持超过一千种开发板<sup>[4](https://www.zephyrproject.org/)</sup> |

## 历史

Zephyr 的前身代码源自英特尔子公司风河，其为 2015 年 11 月推出的 Wind River Rocket 操作系统所开发的内核本质上就是 Zephyr 的商业版本；风河将该 Rocket 内核贡献给了该项目<sup>[9](https://www.windriver.com/blog/wind-river-welcomes-linux-foundations-zephyr-project)</sup>。首批代码于 2014 年底由风河通过基于 VxMicro 的合作提供，这些代码已在部分产品上作为 RTOS 运行，包括一些英特尔笔记本电脑<sup>[2](https://www.intel.com/content/www/us/en/developer/articles/community/zephyr-story-how-became-self-sustaining-ecosystem.html)</sup>。

Linux 基金会于 2016 年 2 月宣布 Zephyr 项目，作为一个开源协作项目，旨在为物联网设备构建一个小占用、模块化、可扩展的联网实时操作系统，早期获得英特尔（包括 Altera 和风河）及[恩智浦半导体](https://www.edgepedia.org/zh/nxp-semiconductors)的支持<sup>[5](https://www.acnnewswire.com/press-release/japanese/28179/linux-foundation%E3%80%81%E3%83%A2%E3%83%8E%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%BF%E3%83%BC%E3%83%8D%E3%83%83%E3%83%88%EF%BC%88iot%EF%BC%89%E5%90%91%E3%81%91%E3%83%AA%E3%82%A2%E3%83%AB%E3%82%BF%E3%82%A4%E3%83%A0%E3%82%AA%E3%83%9A%E3%83%AC%E3%83%BC%E3%83%86%E3%82%A3%E3%83%B3%E3%82%B0%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0%E6%A7%8B%E7%AF%89%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%82%92%E7%99%BA%E8%A1%A8)</sup>。从 2014 年底首次内部公告到公开发布之间，项目累积了约七千次提交，将其专有构建系统全面改造为 Linux 风格的 Kbuild，引入了受 Linux 启发的设备模型，发布时支持四种开发板：Arduino 101、NXP FRDM-K64F、Arduino Due 和 [Intel Galileo](https://www.edgepedia.org/zh/intel-galileo)<sup>[2](https://www.intel.com/content/www/us/en/developer/articles/community/zephyr-story-how-became-self-sustaining-ecosystem.html)</sup>。

两个早期决策塑造了该项目。Zephyr 最初采用 BSD 许可证，但应早期合作伙伴的要求改为 Apache License 2.0；项目自己的记录指出，由于 Zephyr 常与 Linux 主机软件配合使用，Apache 与 GPLv2 的不兼容性仍是一个反复出现的问题<sup>[2](https://www.intel.com/content/www/us/en/developer/articles/community/zephyr-story-how-became-self-sustaining-ecosystem.html)</sup>。构建系统后来从 Kbuild 迁移到 CMake，原因是 Kbuild 在 Windows 上表现不佳<sup>[2](https://www.intel.com/content/www/us/en/developer/articles/community/zephyr-story-how-became-self-sustaining-ecosystem.html)</sup>。

## 内核与线程模型

Zephyr 线程是一种内核对象，用于处理对于中断服务程序而言过于冗长或复杂的应用处理。可定义任意数量的线程，仅受可用 RAM 限制。每个线程拥有一个栈区域、一个类型为 `k_thread` 的控制块、一个最多接受 3 个参数的入口函数、一个调度优先级、一组线程选项、一个启动延迟以及一个执行模式——超级用户模式或用户模式<sup>[10](https://docs.zephyrproject.org/latest/kernel/services/threads/index.html)</sup>。默认情况下，线程以超级用户模式运行，可访问特权 CPU 指令、整个内存地址空间及外设<sup>[10](https://docs.zephyrproject.org/latest/kernel/services/threads/index.html)</sup>。

内核基于优先级的调度器选择最高优先级的就绪线程作为当前线程；在同等优先级的就绪线程中，选择等待时间最长的一个。启用最早截止时间优先调度（`CONFIG_SCHED_DEADLINE`）时，在静态优先级相同的线程中，截止时间更早的线程被视为具有更高优先级<sup>[11](https://d25yug97gus487.cloudfront.net/latest/kernel/services/scheduling/index.html)</sup>。Zephyr 同时支持可抢占线程和协作线程，就绪队列的实现是编译时的选择，在代码大小、运行时开销和大量线程下的可扩展性之间权衡<sup>[11](https://d25yug97gus487.cloudfront.net/latest/kernel/services/scheduling/index.html)</sup><sup> • </sup><sup>[12](https://github.com/zephyrproject-rtos/zephyr/blob/main/doc/hardware/porting/arch.rst)</sup>。

**栈对象。** 每个线程都需要自己的栈缓冲区。Zephyr 区分“内核”栈和“线程”栈：前者用 `K_KERNEL_STACK` 宏定义，承载超级用户模式线程或中断处理，对齐要求较宽松；后者用 `K_THREAD_STACK` 宏定义，占用更多内存但可承载用户模式线程。若未启用 `CONFIG_USERSPACE`，两者等价<sup>[10](https://docs.zephyrproject.org/latest/kernel/services/threads/index.html)</sup><sup> • </sup><sup>[12](https://github.com/zephyrproject-rtos/zephyr/blob/main/doc/hardware/porting/arch.rst)</sup>。启用用户空间后，线程栈的大小和对齐必须使一个内存保护区域恰好适配，并为系统调用处理保留一个独立的固定大小特权提升栈；某些 MPU 要求区域大小为 2 的幂且按自身大小对齐，因此可移植代码向 `k_thread_create()` 传递专门实例化的栈对象而非任意缓冲区<sup>[10](https://docs.zephyrproject.org/latest/kernel/services/threads/index.html)</sup>。

## 用户模式与内存保护

用户模式线程被视为不可信，彼此隔离并与内核隔离。用户线程只能访问部分内存，通常为其栈、程序代码、只读数据及其所属内存域中的任何分区；访问其他 RAM 需要通过系统调用，或由超级用户线程通过内存域 API 授予访问权限，新线程继承父线程的内存域配置<sup>[13](https://docs.zephyrproject.org/latest/kernel/usermode/overview.html)</sup>。用户线程不能直接访问属于内核对象的内存，包括设备驱动和线程栈；操作通过系统调用接口进行，默认情况下用户线程仅对自身的线程对象有权限<sup>[13](https://docs.zephyrproject.org/latest/kernel/usermode/overview.html)</sup>。

内存保护设计面向带有 MPU（内存保护单元）的微控制器；内核确保每个用户线程可访问自己的栈缓冲区以及程序代码和只读数据<sup>[14](https://docs.zephyrproject.org/latest/kernel/usermode/memory_domain.html)</sup>。执行保护分阶段引入：栈保护自 1.9.0 版本起提供，内存保护和线程隔离在 1.10.0 中针对 x86 引入，在 1.11.0 中针对 ARM 和 ARC 引入<sup>[8](https://docs.zephyrproject.org/latest/security/security-overview.html)</sup>。

文档明确列出了限制。Zephyr 没有线程优先级老化机制，因此某一优先级的用户线程可能饿死所有更低优先级的线程，若未启用时间分片，也可能饿死同优先级的线程；同时活跃的线程数量有编译时限制；内核无法防止在内核模式下进行的内存域配置错误<sup>[13](https://docs.zephyrproject.org/latest/kernel/usermode/overview.html)</sup>。

## 安全架构

安全架构为单体式：Zephyr 内核和所有应用程序编译为单一静态二进制文件，系统调用以函数调用方式实现，无上下文切换。静态链接消除了动态加载恶意代码的可能性，栈、线程执行级别和内存保护约束在上下文切换时强制执行<sup>[8](https://docs.zephyrproject.org/latest/security/security-overview.html)</sup>。密码学功能通过 PSA Crypto 提供，底层实现为 Mbed TLS<sup>[8](https://docs.zephyrproject.org/latest/security/security-overview.html)</sup>。

项目的安全最佳实践文档界定了内核不覆盖的范围：由于性能和内存占用成本，不提供内核内的拒绝服务攻击防护；不检测对已加载镜像或内存区域的篡改，须由安全启动、可信执行或应用层检查处理；不对 I/O 接口上的恶意输入进行净化，此为应用程序的责任<sup>[15](https://github.com/zephyrproject-rtos/zephyr/wiki/Security-Best-Practices)</sup>。

## 配置与硬件支持

Zephyr 高度可配置且模块化：应用程序仅纳入所需功能并指定其数量和大小，系统资源在编译时定义以减小代码体积<sup>[3](https://docs.zephyrproject.org/latest/introduction)</sup>。硬件通过设备树描述，其信息用于创建应用程序镜像，设备驱动模型提供一致的配置、初始化和跨平台驱动复用<sup>[3](https://docs.zephyrproject.org/latest/introduction)</sup>。对于无 MMU 或 MPU 的平台以及内存受限的设备，Zephyr 支持将应用特定代码与自定义内核组合为单一镜像，应用程序和内核代码在单一共享地址空间中执行<sup>[3](https://docs.zephyrproject.org/latest/introduction)</sup>。此外还提供兼容 POSIX pthreads 的 API<sup>[3](https://docs.zephyrproject.org/latest/introduction)</sup>。

## 版本与生态

Zephyr 以源代码和构建脚本形式分发，通过项目的元工具 West 获取<sup>[6](https://docs.zephyrproject.org/latest/releases/index.html)</sup>。4.4.0 版本（2026 年 4 月）是新的半年发布节奏（每年 4 月和 10 月各一版）下的首个版本，吸引了超过 930 名个人贡献者，最低 C 标准移至 C17，随附 Zephyr SDK 1.0 并提供实验性 Clang/LLVM 支持，新增 [OpenRISC](https://www.edgepedia.org/zh/openrisc) 架构支持<sup>[6](https://docs.zephyrproject.org/latest/releases/index.html)</sup><sup> • </sup><sup>[7](https://www.zephyrproject.org/zephyr-rtos-4-4-now-available-wireguard-wi-fi-direct-openrisc-and-more/)</sup>。

厂商采用规模可观。[Nordic Semiconductor](https://www.edgepedia.org/zh/nordic-semiconductor) 经过长时间预研和上游贡献后，采用 Zephyr 作为其 nRF Connect SDK 的基础，为其无线 SoC 用户提供了一个在 GitHub 上公开开发的统一 SDK<sup>[16](https://www.zephyrproject.org/leveraging-open-source-software-in-your-software-development-kit-nordic-semiconductors-experience-with-the-zephyr-rtos/)</sup>。2026 年 3 月 Linux 基金会为纪念项目十周年发布的研究报告发现，70% 的北美受访组织已在产品中使用 Zephyr，69% 计划加大采用力度<sup>[17](https://www.zephyrproject.org/announcements/)</sup>。

独立比较将 Zephyr 与 FreeRTOS 和实时 Linux 进行对照。2024 年的一项对比分析发现，Zephyr 在上下文切换时间和中断延迟方面快于 FreeRTOS，而 FreeRTOS 在互斥锁阻塞与解除阻塞操作上表现更好<sup>[18](https://iirid.utem.edu.my/~documents/proceedings/2024/08-a-comprehensive-comparative-analysis-of-freertos-and-zephyr-os-for-embedded-and-iot-systems/?layout=default)</sup>。生态比较指出 Zephyr 相比 FreeRTOS 开箱即用的额外能力，包括追踪子系统和 `native_sim` 目标——后者将 Zephyr 应用程序编译为原生 Linux 二进制文件，无需硬件即可在主机端测试<sup>[19](https://hubble.com/community/comparisons/zephyr-vs-freertos-for-iot-in-2026-memory-footprint-ecosystem-and-devex-compared)</sup>。

## References

1. [About the Zephyr Project, Zephyr Project](https://www.zephyrproject.org/learn-about/)
2. [The Zephyr Story: How It Became a Self-Sustaining Ecosystem, Intel Developer](https://www.intel.com/content/www/us/en/developer/articles/community/zephyr-story-how-became-self-sustaining-ecosystem.html)
3. [Introduction, Zephyr Project Documentation](https://docs.zephyrproject.org/latest/introduction)
4. [Zephyr Project homepage](https://www.zephyrproject.org/)
5. [Linux Foundation announces IoT RTOS project (Japanese press release), ACN Newswire, February 18, 2016](https://www.acnnewswire.com/press-release/japanese/28179/linux-foundation%E3%80%81%E3%83%A2%E3%83%8E%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%BF%E3%83%BC%E3%83%8D%E3%83%83%E3%83%88%EF%BC%88iot%EF%BC%89%E5%90%91%E3%81%91%E3%83%AA%E3%82%A2%E3%83%AB%E3%82%BF%E3%82%A4%E3%83%A0%E3%82%AA%E3%83%9A%E3%83%AC%E3%83%BC%E3%83%86%E3%82%A3%E3%83%B3%E3%82%B0%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0%E6%A7%8B%E7%AF%89%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%82%92%E7%99%BA%E8%A1%A8)
6. [Releases, Zephyr Project Documentation](https://docs.zephyrproject.org/latest/releases/index.html)
7. [Zephyr RTOS 4.4 Now Available: WireGuard, Wi-Fi Direct, OpenRISC, and More, Zephyr Project](https://www.zephyrproject.org/zephyr-rtos-4-4-now-available-wireguard-wi-fi-direct-openrisc-and-more/)
8. [Zephyr Security Overview, Zephyr Project Documentation](https://docs.zephyrproject.org/latest/security/security-overview.html)
9. [Wind River: Harnessing Linux Foundation's Zephyr for IoT, Wind River](https://www.windriver.com/blog/wind-river-welcomes-linux-foundations-zephyr-project)
10. [Threads, Zephyr Project Documentation](https://docs.zephyrproject.org/latest/kernel/services/threads/index.html)
11. [Scheduling, Zephyr Project Documentation](https://d25yug97gus487.cloudfront.net/latest/kernel/services/scheduling/index.html)
12. [Architecture porting guide, zephyrproject-rtos/zephyr on GitHub](https://github.com/zephyrproject-rtos/zephyr/blob/main/doc/hardware/porting/arch.rst)
13. [User mode overview, Zephyr Project Documentation](https://docs.zephyrproject.org/latest/kernel/usermode/overview.html)
14. [Memory Protection Design, Zephyr Project Documentation](https://docs.zephyrproject.org/latest/kernel/usermode/memory_domain.html)
15. [Security Best Practices, zephyrproject-rtos/zephyr Wiki](https://github.com/zephyrproject-rtos/zephyr/wiki/Security-Best-Practices)
16. [Leveraging open source software in your SDK: Nordic Semiconductor's experience with the Zephyr RTOS, Zephyr Project](https://www.zephyrproject.org/leveraging-open-source-software-in-your-software-development-kit-nordic-semiconductors-experience-with-the-zephyr-rtos/)
17. [Press Releases, Zephyr Project](https://www.zephyrproject.org/announcements/)
18. [A Comprehensive Comparative Analysis of FreeRTOS and Zephyr OS for Embedded and IoT Systems, iIRID'24 Proceedings](https://iirid.utem.edu.my/~documents/proceedings/2024/08-a-comprehensive-comparative-analysis-of-freertos-and-zephyr-os-for-embedded-and-iot-systems/?layout=default)
19. [Zephyr vs FreeRTOS for IoT in 2026, Hubble Network Community](https://hubble.com/community/comparisons/zephyr-vs-freertos-for-iot-in-2026-memory-footprint-ecosystem-and-devex-compared)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Operating systems

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/zephyr-operating-system

English original: https://www.edgepedia.org/zephyr-operating-system
