掌握FreeRTOS™实时内核--前言


Real Time Kernel – 掌握FreeRTOS™实时内核)

在这里插入图片描述

综述

本文章是一系列文章,是作者为了学习freertos,并加深自己的理解。本系列并无技术水平,文章是对Mastering the FreeRTOS™ Real Time Kernel 的翻译。

Preface(前言)

Multitasking in Small Embedded Systems(小型嵌入式系统中的多任务处理)


About FreeRTOS(关于freertos)

FreeRTOS is solely owned, developed and maintained by Real Time Engineers Ltd. Real Time Engineers Ltd. have been working in close partnership with the world’s leading chip companies for well over a decade to provide you award winning, commercial grade, and completely free high quality software.
FreeRTOS 由 Real Time Engineers Ltd 独家拥有、开发和维护。十多年来,Real Time Engineers Ltd. 一直与世界领先的芯片公司密切合作,为您提供屡获殊荣的商业级且完全免费的高质量软件。

FreeRTOS is ideally suited to deeply embedded real-time applications that use microcontrollers or small microprocessors. This type of application normally includes a mix of both hard and soft real-time requirements.
FreeRTOS 非常适合使用微控制器或小型微处理器的深度嵌入式实时应用程序。此类应用通常同时包含硬实时和软实时要求。

Soft real-time requirements are those that state a time deadline—but breaching the deadline would not render the system useless. For example, responding to keystrokes too slowly might make a system seem annoyingly unresponsive without actually making it unusable.
软实时要求是那些规定时间期限的要求,但违反期限并不会使系统变得无用。例如,对击键的响应太慢可能会使系统看起来反应迟钝,但实际上却无法使用。

Hard real-time requirements are those that state a time deadline—and breaching the deadline would result in absolute failure of the system. For example, a driver’s airbag has the potential to do more harm than good if it responded to crash sensor inputs too slowly.
硬实时要求是那些规定时间期限的要求,违反期限将导致系统绝对失败。例如,如果驾驶员的安全气囊对碰撞传感器输入的响应太慢,则可能弊大于利。

FreeRTOS is a real-time kernel (or real-time scheduler) on top of which embedded applications can be built to meet their hard real-time requirements. It allows applications to be organized as a collection of independent threads of execution. On a processor that has only one core, only a single thread can be executing at any one time. The kernel decides which thread should be executing by examining the priority assigned to each thread by the application designer. In the simplest case, the application designer could assign higher priorities to threads that implement hard real-time requirements, and lower priorities to threads that implement soft real-time requirements. This would ensure that hard real-time threads are always executed ahead of soft real-time threads, but priority assignment decisions are not always that simplistic.
FreeRTOS 是一个实时内核(或实时调度程序),可以在其上构建嵌入式应用程序以满足其硬实时要求。它允许将应用程序组织为独立执行线程的集合。在只有一个核心的处理器上,任何时候只能执行一个线程。内核通过检查应用程序设计者分配给每个线程的优先级来决定应该执行哪个线程。在最简单的情况下,应用程序设计者可以为实现硬实时要求的线程分配较高的优先级,为实现软实时要求的线程分配较低的优先级。这将确保硬实时线程始终先于软实时线程执行,但优先级分配决策并不总是那么简单。

Do not be concerned if you do not fully understand the concepts in the previous paragraph yet. The following chapters provide a detailed explanation, with many examples, to help you understand how to use a real-time kernel, and how to use FreeRTOS, in particular.
如果您尚未完全理解上一段中的概念,请不要担心。以下章节提供了详细的解释,并带有许多示例,帮助您了解如何使用实时内核,特别是如何使用 FreeRTOS。

Value Proposition(价值主张)

The unprecedented global success of FreeRTOS comes from its compelling value proposition; FreeRTOS is professionally developed, strictly quality controlled, robust, supported, does not contain any intellectual property ownership ambiguity, and is truly free to use in commercial applications without any requirement to expose your proprietary source code. You can take a product to market using FreeRTOS without even talking to Real Time Engineers ltd., let alone paying any fees, and thousands of people do just that. If, at any time, you would like to receive additional backup, or if your legal team require additional written guarantees or indemnification, then there is a simple low cost commercial upgrade path. Peace of mind comes with the knowledge that you can opt to take the commercial route at any time you choose.
FreeRTOS 在全球范围内取得的空前成功源自其引人注目的价值主张; FreeRTOS 是专业开发的,严格的质量控制,强大,受支持,不包含任何知识产权所有权模糊性,并且真正免费在商业应用程序中使用,无需公开您的专有源代码。您可以使用 FreeRTOS 将产品推向市场,甚至无需与 Real Time Engineers ltd. 交谈,更不用说支付任何费用,成千上万的人就是这样做的。如果您随时希望获得额外的备份,或者您的法律团队需要额外的书面保证或赔偿,那么有一个简单的低成本商业升级路径。当您知道您可以随时选择走商业路线时,您就可以安心无忧。

A Note About Terminology(关于术语的注释)

In FreeRTOS, each thread of execution is called a ‘task’. There is no consensus on terminology within the embedded community, but I prefer ‘task’ to ‘thread,’ as thread can have a more specific meaning in some fields of application.
在 FreeRTOS 中,每个执行线程称为“任务”。嵌入式社区内的术语尚未达成共识,但我更喜欢“任务”而不是“线程”,因为线程在某些应用领域可以有更具体的含义。
注:作者这里认为就是一个理解问题,读者应该顺从自己便于理解的方式来理解并阅读文章

Why Use a Real-time Kernel?(为什么使用实时内核?)

There are many well established techniques for writing good embedded software without the use of a kernel, and, if the system being developed is simple, then these techniques might provide the most appropriate solution. In more complex cases, it is likely that using a kernel would be preferable, but where the crossover point occurs will always be subjective.
有许多成熟的技术可以在不使用内核的情况下编写良好的嵌入式软件,并且如果正在开发的系统很简单,那么这些技术可能提供最合适的解决方案。在更复杂的情况下,使用内核可能会更好,但交叉点发生的位置始终是主观的。

As already described, task prioritization can help ensure an application meets its processing deadlines, but a kernel can bring other less obvious benefits, too. Some of these are listed very briefly below.
如前所述,任务优先级可以帮助确保应用程序满足其处理期限,但内核也可以带来其他不太明显的好处。下面简要列出了其中一些。

  • Abstracting away timing information
    The kernel is responsible for execution timing and provides a time-related API to the application. This allows the structure of the application code to be simpler, and the overall code size to be smaller

  • 抽象出计时信息
    内核负责执行计时并向应用程序提供与时间相关的API。这使得应用程序代码的结构更加简单,并且整体代码大小更小。.

  • Maintainability/Extensibility
    Abstracting away timing details results in fewer interdependencies between modules, and allows the software to evolve in a controlled and predictable way. Also, the kernel is responsible for timing, so application performance is less susceptible to changes in the underlying hardware.

  • 可维护性/可扩展性
    抽象出时序细节会减少模块之间的相互依赖性,并允许软件以受控和可预测的方式发展。此外,内核负责计时,因此应用程序性能不太容易受到底层硬件变化的影响。

  • Modularity
    Tasks are independent modules, each of which should have a well-defined purpose.

  • 模块性
    任务是独立的模块,每个模块都应该有明确的目的。

  • Team development
    Tasks should also have well-defined interfaces, allowing easier development by teams

  • 团队发展
    任务还应该具有明确定义的接口,以便团队更轻松地进行开发

  • Easier testing
    If tasks are well-defined independent modules with clean interfaces, they can be tested in isolation.

  • 测试容易
    如果任务是具有清晰接口的明确定义的独立模块,则可以单独测试它们。

  • Code reuse
    Greater modularity and fewer interdependencies results in code that can be reused with less effort.

  • 代码移植
    更高的模块化性和更少的相互依赖性使得代码可以更轻松地进行移植。

  • Improved efficiency
    Using a kernel allows software to be completely event-driven, so no processing time is wasted by polling for events that have not occurred. Code executes only when there is something that must be done.

Counter to the efficiency saving is the need to process the RTOS tick interrupt, and to switch execution from one task to another. However, applications that don’t make use of an RTOS normally include some form of tick interrupt anyway.

  • 效率更高
    使用内核允许软件完全由事件驱动,因此不会因轮询未发生的事件而浪费处理时间。仅当有必须完成的事情时才会执行代码。
    与节省效率相反的是需要处理 RTOS 节拍中断,并将执行从一个任务切换到另一个任务。然而,不使用 RTOS 的应用程序通常无论如何都会包含某种形式的滴答中断。

  • Idle time
    The Idle task is created automatically when the scheduler is started. It executes whenever there are no application tasks wishing to execute. The idle task can be used to measure spare processing capacity, to perform background checks, or simply to place the processor into a low-power mode

  • 空闲时间
    空闲任务是在调度程序启动时自动创建的。只要没有希望执行的应用程序任务,它就会执行。空闲任务可用于测量空闲处理能力、执行后台检查或简单地将处理器置于低功耗模式。

  • Power Management
    The efficiency gains that are obtained by using an RTOS allow the processor to spend more time in a low power mode.
    Power consumption can be decreased significantly by placing the processor into a low power state each time the Idle task runs. FreeRTOS also has a special tick-less mode. Using the tick-less mode allows the processor to enter a lower power mode than would otherwise be possible, and remain in the low power mode for longer.

  • 电源管理
    使用 RTOS 获得的效率增益允许处理器在低功耗模式下花费更多时间。
    每次空闲任务运行时,通过将处理器置于低功耗状态,可以显著降低功耗。FreeRTOS还具有特殊的无时钟模式。使用无时钟模式允许处理器进入比其他情况下更低功耗的模式,并保持更长时间的低功耗模式

  • Flexible interrupt handling
    Interrupt handlers can be kept very short by deferring processing to either a task created by the application writer, or the FreeRTOS daemon task.

  • 灵活的终端处理
    通过将处理推迟到应用程序编写者创建的任务或 FreeRTOS 守护程序任务,可以使中断处理程序保持非常短。

  • Mixed processing requirements
    Simple design patterns can achieve a mix of periodic, continuous and event-driven processing within an application. In addition, hard and soft real-time requirements can be met by selecting appropriate task and interrupt priorities.

  • 混合处理需求

  • 简单的设计模式可以在应用程序中实现周期性、连续和事件驱动处理的混合。此外,通过选择适当的任务和中断优先级可以满足硬实时和软实时要求。

FreeRTOS Features(FreeRTOS 功能)

FreeRTOS has the following standard features:

  • Pre-emptive or co-operative operation
  • Very flexible task priority assignment
  • Flexible, fast and light weight task notification mechanism
  • Queues
  • Binary semaphores
  • Counting semaphores
  • Mutexes
  • Recursive Mutexes
  • Software timers
  • Event groups
  • Tick hook functions
  • Idle hook functions
  • Stack overflow checking
  • Trace recording
  • Task run-time statistics gathering
  • Optional commercial licensing and support
  • Full interrupt nesting model (for some architectures)
  • A tick-less capability for extreme low power applications
  • Software managed interrupt stack when appropriate (this can help save RAM)

FreeRTOS具有以下标准功能:

  • 抢占式或协作式操作
  • 非常灵活的任务优先级分配
  • 灵活、快速和轻量级的任务通知机制
  • 队列
  • 二进制信号量
  • 计数信号量
  • 互斥锁
  • 递归互斥锁
  • 软件定时器
  • 事件组
  • 中断钩子函数
  • 空闲钩子函数
  • 栈溢出检查
  • 跟踪记录
  • 任务运行时统计信息收集
  • 可选的商业许可和支持
  • 完全的中断嵌套模型(针对某些体系结构)
  • 适用于极端低功耗应用的无计时器功能
  • 在适当情况下,由软件管理的中断堆栈(有助于节省RAM)

Licensing, and The FreeRTOS, OpenRTOS, and SafeRTOS Family(许可以及 FreeRTOS、OpenRTOS 和 SafeRTOS 系列)

Licensing, and The FreeRTOS, OpenRTOS, and SafeRTOS Family
The FreeRTOS open source license is designed to ensure:

  1. FreeRTOS can be used in commercial applications.
  2. FreeRTOS itself remains freely available to everybody.
  3. FreeRTOS users retain ownership of their intellectual property.
    See http://www.FreeRTOS.org/license for the latest open source license information. OpenRTOS is a commercially licensed version of FreeRTOS provided under license from Real Time Engineers Ltd. by a third party.
    SafeRTOS shares the same usage model as FreeRTOS, but has been developed in accordance with the practices, procedures, and processes necessary to claim compliance with various internationally recognized safety related standards.

许可以及 FreeRTOS、OpenRTOS 和 SafeRTOS 系列 FreeRTOS 开源许可证旨在确保:

  1. FreeRTOS 可用于商业应用程序。
  2. FreeRTOS 本身仍然可供所有人免费使用。
  3. FreeRTOS 用户保留其知识产权的所有权。
    请参阅 http://www.FreeRTOS.org/license 了解最新的开源许可证信息。
    OpenRTOS 是 FreeRTOS 的商业许可版本,由第三方根据 Real Time Engineers Ltd. 的许可提供。
    SafeRTOS 与 FreeRTOS 具有相同的使用模型,但是根据声明符合各种国际公认的安全相关标准所需的实践、程序和流程进行开发的

Included Source Files and Projects(包含的源文件和项目)

Obtaining the Examples that Accompany this Book(获取本书的示例)

Source code, pre-configured project files, and full build instructions for all the examples presented in this book are provided in an accompanying zip file. You can download the zip file from http://www.FreeRTOS.org/Documentation/code if you did not receive a copy with the book. The zip file may not include the latest version of FreeRTOS.
The screen shots included in this book were taken while the examples were executing in a Microsoft Windows environment, using the FreeRTOS Windows port. The project that uses the FreeRTOS Windows port is pre-configured to build using the free Express edition of Visual Studio, which can be downloaded from http://www.microsoft.com/express. Note that, while the FreeRTOS Windows port provides a convenient evaluation, test and development platform, it does not provide true real-time behavior.
随附的 zip 文件中提供了本书中所有示例的源代码、预配置项目文件和完整构建说明。如果您没有随本书一起收到副本,可以从 http://www.FreeRTOS.org/Documentation/code 下载 zip 文件。该 zip 文件可能不包含最新版本的 FreeRTOS。
本书中包含的屏幕截图是在 Microsoft Windows 环境中使用 FreeRTOS Windows 端口执行示例时拍摄的。使用 FreeRTOS Windows 端口的项目已预先配置为使用 Visual Studio 的免费 Express 版本进行构建,可以从 http://www.microsoft.com/express 下载该版本。请注意,虽然 FreeRTOS Windows 端口提供了方便的评估、测试和开发平台,但它并不提供真正的实时行为。

  • 20
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值