Introduction to Real-Time Kernels_real time kernel-程序员宅基地

技术标签: 【Linux内核】  

目录

What is a Real-Time Kernel?

Evaluation Boards

Micrium’s µC/Probe

Texas Instruments’ EVALBOT

Summary


 

This article describes how you can get started with learning about the internals of real-time kernels using a commercial grade kernel, running on actual hardware and using professional grade tools, all for next to nothing.

本文介绍了如何使用商业级内核,在实际硬件上运行以及使用专业级工具来学习实时内核的内部知识,而这一切几乎没有。

 

What is a Real-Time Kernel?


A real-time kernel is software that manages the time of a CPU (Central Processing Unit) or MPU (Micro Processing Unit) as efficiently as possible. Most kernels are written in C and require a small portion of code written in assembly language in order to adapt the kernel to different CPU architectures.

A kernel provides many useful services to a programmer such as multitasking, interrupt management, inter-task communication and signaling, resource management, time management, memory partition management and more. Most kernels used for embedded systems are ‘preemptive’ meaning that the kernel always executes the most important task that is ready to run. Preemptive kernels are also event driven which basically means that tasks are designed to wait for events to occur in order to execute. For example, a task could wait for a packet to be received on an Ethernet controller, another task could wait for a timer to expire, yet another task can wait for a character to be received on a UART, etc. When the event occurs, the task executes and performs its function. If the event that the task is waiting for doesn’t occur, the kernel runs other tasks. Waiting task consume zero CPU time. Kernels allow you to avoid polling loops which is a bad use of the CPU’s time.

实时内核是一种软件,它可以尽可能高效地管理CPU(中央处理单元)或MPU(微处理单元)的时间。大多数内核都是用C编写的,并且需要一小部分用汇编语言编写的代码才能使内核适应不同的CPU架构。

内核为程序员提供了许多有用的服务,例如多任务处理,中断管理,任务间通信和信令,资源管理,时间管理,内存分区管理等等。嵌入式系统中使用的大多数内核都是“抢先式”的,这意味着内核总是执行准备运行的最重要的任务。抢占式内核也是事件驱动的,这基本上意味着任务被设计为等待事件发生才能执行。例如,一个任务可以等待在以太网控制器上接收到数据包,另一个任务可以等待计时器到期,而另一个任务可以等待在UART上接收字符,等等。当事件发生时,任务执行并执行其功能。如果没有发生任务正在等待的事件,则内核将运行其他任务。等待的任务消耗零的CPU时间。内核使您可以避免轮询循环,这会浪费CPU时间。

Real-time kernels are not limited to high end 32-bit CPUs and in fact, a kernel like Micrium’s µC/OS-III can run comfortably on many 8 and 16-bit CPUs or even DSP (Digital Signal Processing) chips.

Many embedded programmers shy away from using a kernel because they fear that kernels add too much complexity to their application. It turns out that you only need a handful of services to get your project off the ground with a kernel. For example, with µC/OS-III, you can write fairly complex multitasking application with as little as five (5) API functions out of the nearly 70 API calls offered by µC/OS-III.

实时内核不仅限于高端32位CPU,实际上,像Micrium的µC / OS-III这样的内核可以在许多8位和16位CPU甚至DSP(数字信号处理)芯片上轻松运行。

许多嵌入式程序员回避使用内核,因为他们担心内核会给应用程序增加太多的复杂性。事实证明,您只需要少量服务即可使用内核启动您的项目。例如,使用µC / OS-III,您可以使用µC / OS-III提供的近70个API调用中的五(5)个API函数编写相当复杂的多任务应用程序。

Years ago, embedded systems used to be designed by first selecting the microprocessor or microcontroller, then the tools (compiler, assembler, linker and debugger) and finally, you’d figure out how to write the software. Nowadays, many embedded systems are designed by starting with the software requirements and in fact, determining what software components you can purchase off-the-shelf to satisfy your needs. A real-time kernel is one such component and in fact, is generally the first software component you’ll need to select because it establishes the framework upon which you can build your product. Having a kernel allows you to easily add other software components such as a TCP/IP stack, a USB stack (host or device), a file system, a graphical user interface (or GUI) and more. Some of these software components are easy to use but are quite complex to develop. For example, a TCP/IP stack can consist of well over 100,000 lines of C code but, from the application’s programmer’s point of view, you only need to understand and use about 30 or so API functions. In other words, far easier to use that to create.

多年以前,嵌入式系统的设计首先是选择微处理器或微控制器,然后选择工具(编译器,汇编器,链接器和调试器),最后选择如何编写软件。如今,许多嵌入式系统的设计都是从软件需求入手,实际上是确定可以购买现成的软件组件来满足您的需求。实时内核就是这样一个组件,实际上,它通常是您需要选择的第一个软件组件,因为它建立了可用来构建产品的框架。有了内核,您可以轻松添加其他软件组件,例如TCP / IP堆栈,USB堆栈(主机或设备),文件系统,图形用户界面(或GUI)等。这些软件组件中的某些易于使用,但开发却相当复杂。例如,一个TCP / IP堆栈可以包含100,000行以上的C代码,但是从应用程序程序员的角度来看,您只需要了解和使用大约30个左右的API函数即可。换句话说,使用它来创建要容易得多。

The internals of the µC/OS-III real-time kernel are described in a book I wrote called: µC/OS-III, The Real-Time Kernel. There are in fact six different versions of this book, each featuring a different CPU architecture. Each of these books is available as a free PDF download from the Micrium website.

I personally prefer an actual book so, if you are like me, you can purchase the hardcover book either from Micrium, one of our authorized distributors or Amazon.com.

µC/OS-III is ‘Source Available’ meaning that you can download the FULL source code for µC/OS-III and use it for FREE as long as it’s for educational use or for peaceful research. However, you need to purchase a license (i.e. the rights to use µC/OS-III) if you intend to use µC/OS-III in commercial products or applications.

我写的一本书《 µC / OS-III,实时内核》中介绍了µC / OS-III实时内核的内部结构。实际上,本书有六个不同的版本,每个版本具有不同的CPU架构。这些书中的每本书都可以从Micrium网站免费下载PDF 。

我个人更喜欢一本实际的书,因此,如果您像我一样,可以从我们的授权发行商之一Micrium或Amazon.com购买精装书。

µC / OS-III是“可用的源”,这意味着您可以下载µC / OS-III的完整源代码,并免费使用,只要用于教育或和平研究即可。但是,如果您打算在商业产品或应用中使用µC / OS-III,则需要购买许可证(即使用µC / OS-III的权利)。

 

Evaluation Boards


An evaluation board is available with each book, allowing the reader to not only learn about what real-time kernels are and how they work but also be able to perform actual experiments on actual hardware.

In order to run the examples provided with each book, you will need to download the code corresponding with the book you are interested in (that depends on what CPU manufacturer or CPU architecture you prefer). The companion projects for each book are available as free downloads from the same web page as shown above.

Finally, each book requires ‘tools’ to allow you to compile and download the example code. The tools that you will need depend on which book and board you get. Evaluation versions of tools can be downloaded for free and links to those are provided in each book. In all cases, you will have to register in order to be able to download these tools.

每本书都有一个评估板,读者不仅可以了解实时内核及其工作原理,还可以在实际硬件上进行实际实验。

为了运行每本书提供的示例,您需要下载与您感兴趣的书相对应的代码(取决于您喜欢的CPU制造商或CPU体系结构)。如上所示,可以从同一网页免费下载每本书的配套项目。

最后,每本书都需要“工具”来允许您编译和下载示例代码。您将需要的工具取决于您所获得的书和纸板。可以免费下载工具的评估版,每本书中都提供了这些工具的链接。在所有情况下,您都必须注册才能下载这些工具。

 

Micrium’s µC/Probe


All of the examples provided with each book make use of a cool tool called µC/Probe which is available from Micrium. Again, a free evaluation version of µC/Probe can be downloaded from the same Micrium web page as previously described.

µC/Probe is an award-winning Microsoft Windows-based application that allows a user to display or change the value (at run time) of virtually any variable or memory location on a connected embedded target. The user simply populates µC/Probe’s graphical environment with gauges, numeric indicators, tables, graphs, virtual LEDs, bar graphs, sliders, switches, push buttons, and other components, and associates each of these to a variable or memory location.

With µC/Probe, it is not necessary to instrument the target code in order to display or change variables at run time. In fact, there is no need to add printf() statements, hardware such as Light Emitting Diodes (LEDs), Liquid Crystal Displays (LCDs), or use any other means to get visibility inside an embedded target at run time.

µC/Probe obtains the values from the target either through a J-Tag interface (Segger J-Link), an RS-232C port or an Ethernet port using TCP/IP. For the latter, a TCP/IP stack such as Micrium’s µC/TCP-IP is necessary. The free version of µC/Probe allows you to display or change up to eight application variables. However, it allows you to monitor any µC/OS-III variable since µC/Probe is ‘µC/OS-III Kernel Aware’. Figure 1 shows an example screenshot of µC/OS-III running on the Texas Instruments EVALBOT. The code for this example is provided in the corresponding book.

每本书提供的所有示例均使用一个名为µC / Probe的凉爽工具,可以从Micrium购买。同样,可以从相同的Micrium网页上下载µC / Probe的免费评估版,如前所述。

µC / Probe是屡获殊荣的基于Microsoft Windows的应用程序,它使用户可以在运行时显示或更改连接的嵌入式目标上几乎任何变量或内存位置的值(在运行时)。用户只需将仪表,数字指示器,表格,图形,虚拟LED,条形图,滑块,开关,按钮和其他组件填充到µC / Probe的图形环境中,然后将它们分别与变量或存储位置关联即可。

使用µC / Probe,无需插装目标代码即可在运行时显示或更改变量。实际上,无需在运行时添加printf()语句,诸如发光二极管(LED),液晶显示器(LCD)之类的硬件,也无需使用任何其他方法来获得嵌入式目标内部的可见性。

µC / Probe通过J-Tag接口(Segger J-Link),RS-232C端口或使用TCP / IP的以太网端口从目标获取值。对于后者,必须使用TCP / IP堆栈,例如Micrium的µC / TCP-IP。µC / Probe的免费版本允许您显示或更改最多八个应用程序变量。但是,由于µC / Probe是“ µC / OS-III内核感知”,它允许您监视任何µC / OS-III变量。图1显示了在德州仪器EVALBOT上运行的µC / OS-III的屏幕截图示例。该示例的代码在相应的书中提供。

Texas Instruments’ EVALBOT


One of the coolest evaluation boards available with a µC/OS-III book is the Texas Instruments EVALBOT which is shown in Figure 2. The EVALBOT is a small robotic device that features a board with a Stellaris LM3S9B92 microcontroller with Ethernet, USB OTG (On-The-Go), and I2S. The kit contains wheels that are easy to attach to the board, a display, batteries, a USB cable, and a CD with the IAR tools, the StellarisWare software, and all the necessary documentation. A block diagram of the electronics found on this board is shown in Figure 3.

The EVALBOT comes as a kit where you assemble all the mechanical components with all the electronics already pre-assembled. You can purchase this kit from Texas Instruments’ online web store or a TI authorized distributor.

It takes about one hour to put together an EVALBOT. The examples provided in the µC/OS-III book will allow you to display text onto the small OLED display, control the LEDs, the motor driving each wheel, reading ‘bumper’ sensors so you can run the EVALBOT in autonomous mode and have it change its course as it hits objects.

µC / OS-III书中可用的最酷的评估板之一是德州仪器(TI)的EVALBOT,如图2所示。EVALBOT是一种小型机器人设备,其电路板带有带以太网的StellarisLM3S9B92微控制器,USB OTG( On-The-Go)和I2S。该套件包含易于安装到板上的轮子,显示器,电池,USB电缆和带有IAR工具,StellarisWare软件以及所有必要文档的CD。图3显示了该板上的电子设备的框图。

EVALBOT作为套件提供,在其中您可以组装所有已预先组装好的所有电子部件的机械部件。您可以从德州仪器(TI)的在线网上商店或TI授权的经销商处购买此套件。

组装一个EVALBOT大约需要一个小时。µC / OS-III书中提供的示例将使您可以在小型OLED显示屏上显示文本,控制LED,驱动每个车轮的电动机,读取“保险杠”传感器,以便您可以在自动模式下运行EVALBOT撞击物体时改变其路线。

 

Summary


A real-time kernel is an increasingly useful software component that allows you to efficiently use the resources of a microprocessor or microcontroller, and create a framework upon which you can build simple or complex applications or products. You can download any or all of six µC/OS-III books in PDF format for FREE. These books describe what a real-time kernel is, what you can do with a real-time kernel and, provides plenty of examples that you can actually try using one of the companion evaluation boards. The source code for µC/OS-III is also available as a FREE download from the Micrium website. If you are an embedded software developer and you are new to real-time kernels then, you will find that a kernel is a useful tool to add to your toolbox. ■

实时内核是一种越来越有用的软件组件,它使您可以有效地使用微处理器或微控制器的资源,并创建一个可以在其上构建简单或复杂的应用程序或产品的框架。您可以免费下载PDF格式的六本µC / OS-III书籍中的任何一本或全部。这些书描述了实时内核是什么,实时内核可以做什么,并提供了大量示例,您可以实际使用其中一个评估板进行尝试。µC / OS-III的源代码也可以从Micrium网站免费下载。如果您是嵌入式软件开发人员,并且不熟悉实时内核,那么您会发现内核是添加到工具箱中的有用工具。■

 

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Rong_Toa/article/details/113728737

智能推荐

FTP命令字和返回码_ftp 登录返回230-程序员宅基地

文章浏览阅读3.5k次,点赞2次,收藏13次。为了从FTP服务器下载文件,需要要实现一个简单的FTP客户端。FTP(文件传输协议) 是 TCP/IP 协议组中的应用层协议。FTP协议使用字符串格式命令字,每条命令都是一行字符串,以“\r\n”结尾。客户端发送格式是:命令+空格+参数+"\r\n"的格式服务器返回格式是以:状态码+空格+提示字符串+"\r\n"的格式,代码只要解析状态码就可以了。读写文件需要登陆服务器,特殊用..._ftp 登录返回230

centos7安装rabbitmq3.6.5_centos7 安装rabbitmq3.6.5-程序员宅基地

文章浏览阅读648次。前提:systemctl stop firewalld 关闭防火墙关闭selinux查看getenforce临时关闭setenforce 0永久关闭sed-i'/SELINUX/s/enforcing/disabled/'/etc/selinux/configselinux的三种模式enforcing:强制模式,SELinux 运作中,且已经正确的开始限制..._centos7 安装rabbitmq3.6.5

idea导入android工程,idea怎样导入Android studio 项目?-程序员宅基地

文章浏览阅读5.8k次。满意答案s55f2avsx2017.09.05采纳率:46%等级:12已帮助:5646人新版Android Studio/IntelliJ IDEA可以直接导入eclipse项目,不再推荐使用eclipse导出gradle的方式2启动Android Studio/IntelliJ IDEA,选择 import project3选择eclipse 项目4选择 create project f..._android studio 项目导入idea 看不懂安卓项目

浅谈AI大模型技术:概念、发展和应用_ai大模型应用开发-程序员宅基地

文章浏览阅读860次,点赞2次,收藏6次。AI大模型技术已经在自然语言处理、计算机视觉、多模态交互等领域取得了显著的进展和成果,同时也引发了一系列新的挑战和问题,如数据质量、计算效率、知识可解释性、安全可靠性等。城市运维涉及到多个方面,如交通管理、环境监测、公共安全、社会治理等,它们需要处理和分析大量的多模态数据,如图像、视频、语音、文本等,并根据不同的场景和需求,提供合适的决策和响应。知识搜索有多种形式,如语义搜索、对话搜索、图像搜索、视频搜索等,它们可以根据用户的输入和意图,从海量的数据源中检索出最相关的信息,并以友好的方式呈现给用户。_ai大模型应用开发

非常详细的阻抗测试基础知识_阻抗实部和虚部-程序员宅基地

文章浏览阅读8.2k次,点赞12次,收藏121次。为什么要测量阻抗呢?阻抗能代表什么?阻抗测量的注意事项... ...很多人可能会带着一系列的问题来阅读本文。不管是数字电路工程师还是射频工程师,都在关注各类器件的阻抗,本文非常值得一读。全文13000多字,认真读完大概需要2小时。一、阻抗测试基本概念阻抗定义:阻抗是元器件或电路对周期的交流信号的总的反作用。AC 交流测试信号 (幅度和频率)。包括实部和虚部。​图1 阻抗的定义阻抗是评测电路、元件以及制作元件材料的重要参数。那么什么是阻抗呢?让我们先来看一下阻抗的定义。首先阻抗是一个矢量。通常,阻抗是_阻抗实部和虚部

小学生python游戏编程arcade----基本知识1_arcade语言 like-程序员宅基地

文章浏览阅读955次。前面章节分享试用了pyzero,pygame但随着想增加更丰富的游戏内容,好多还要进行自己编写类,从今天开始解绍一个新的python游戏库arcade模块。通过此次的《连连看》游戏实现,让我对swing的相关知识有了进一步的了解,对java这门语言也有了比以前更深刻的认识。java的一些基本语法,比如数据类型、运算符、程序流程控制和数组等,理解更加透彻。java最核心的核心就是面向对象思想,对于这一个概念,终于悟到了一些。_arcade语言 like

随便推点

【增强版短视频去水印源码】去水印微信小程序+去水印软件源码_去水印机要增强版-程序员宅基地

文章浏览阅读1.1k次。源码简介与安装说明:2021增强版短视频去水印源码 去水印微信小程序源码网站 去水印软件源码安装环境(需要材料):备案域名–服务器安装宝塔-安装 Nginx 或者 Apachephp5.6 以上-安装 sg11 插件小程序已自带解析接口,支持全网主流短视频平台,搭建好了就能用注:接口是公益的,那么多人用解析慢是肯定的,前段和后端源码已经打包,上传服务器之后在配置文件修改数据库密码。然后输入自己的域名,进入后台,创建小程序,输入自己的小程序配置即可安装说明:上传源码,修改data/_去水印机要增强版

verilog进阶语法-触发器原语_fdre #(.init(1'b0) // initial value of register (1-程序员宅基地

文章浏览阅读557次。1. 触发器是FPGA存储数据的基本单元2. 触发器作为时序逻辑的基本元件,官方提供了丰富的配置方式,以适应各种可能的应用场景。_fdre #(.init(1'b0) // initial value of register (1'b0 or 1'b1) ) fdce_osc (

嵌入式面试/笔试C相关总结_嵌入式面试笔试c语言知识点-程序员宅基地

文章浏览阅读560次。本该是不同编译器结果不同,但是尝试了g++ msvc都是先计算c,再计算b,最后得到a+b+c是经过赋值以后的b和c参与计算而不是6。由上表可知,将q复制到p数组可以表示为:*p++=*q++,*优先级高,先取到对应q数组的值,然后两个++都是在后面,该行运算完后执行++。在电脑端编译完后会分为text data bss三种,其中text为可执行程序,data为初始化过的ro+rw变量,bss为未初始化或初始化为0变量。_嵌入式面试笔试c语言知识点

57 Things I've Learned Founding 3 Tech Companies_mature-程序员宅基地

文章浏览阅读2.3k次。57 Things I've Learned Founding 3 Tech CompaniesJason Goldberg, Betashop | Oct. 29, 2010, 1:29 PMI’ve been founding andhelping run techn_mature

一个脚本搞定文件合并去重,大数据处理,可以合并几个G以上的文件_python 超大文本合并-程序员宅基地

文章浏览阅读1.9k次。问题:先讲下需求,有若干个文本文件(txt或者csv文件等),每行代表一条数据,现在希望能合并成 1 个文本文件,且需要去除重复行。分析:一向奉行简单原则,如无必要,绝不复杂。如果数据量不大,那么如下两条命令就可以搞定合并:cat a.txt >> new.txtcat b.txt >> new.txt……去重:cat new...._python 超大文本合并

支付宝小程序iOS端过渡页DFLoadingPageRootController分析_类似支付宝页面过度加载页-程序员宅基地

文章浏览阅读489次。这个过渡页是第一次打开小程序展示的,点击某个小程序前把手机的开发者->network link conditioner->enable & very bad network 就会在停在此页。比如《支付宝运动》这个小程序先看这个类的.h可以看到它继承于DTViewController点击左上角返回的方法- (void)back;#import "DTViewController.h"#import "APBaseLoadingV..._类似支付宝页面过度加载页

推荐文章

热门文章

相关标签