用Real Time Linux开始编程的最佳方法是什么? [英] What is the best way to start programming with Real Time Linux?

查看:90
本文介绍了用Real Time Linux开始编程的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管我已经用C实现了许多项目,但是我对操作系统完全陌生。我在Discovery板(STM32)上尝试了实时Linux,并获得了正确的LED闪烁结果,但是由于我只是按照步骤进行操作,并且无法在Internet上找到每个步骤的完整说明,因此我并不真正了解整个过程。 p>

我想在实时Linux上实现调度。最好的开始方法是什么?有任何可用的站点,书籍,教程吗?



完整的RTLinux流程描述将受到赞赏。



感谢adv。

解决方案

从裸机到基于OS的编程的过渡是我反向经历的。我最初是一个完整的软件专家,完全涉足OS方面,随着时间的流逝,我转向了相反的方向(甚至在VHDL中设计电路!)。我的建议是从简单开始。 Linux非常复杂,在您所看到的任何地方,都有许多层次的东西协同工作以交付最终产品。如果您对实时Linux扩展不满意,我很乐意建议 https://xenomai.org/

但是,为了更具体地解决有关在Linux中实现调度的问题,您可以,但是这将是一个很大的数目。工作,可能会非常复杂。操作系统使用完全公平的调度过程( http://en.wikipedia.org/wiki/Completely_Fair_Scheduler),每当您启动一个线程时,它只会被添加到列表中以运行。如果您在内核空间中将代码作为驱动程序实现,依赖于硬件中断等,则这可能会略有不同,但是通常,这就是Linux的工作方式。实时通常意味着它能够为多个不同优先级之一分配线程,并在任何给定时间充分利用线程抢占的能力,而这些概念实际上并不是Vanilla Linux的一部分。它对此有一些概念,但是它有局限性,当您从Linux寻找实时行为时可能会引起问题。



RTOS对您可能会有所帮助。如果您正在寻找实时操作系统的完整版,请查看FreeRTOS http://www.freertos.org/。它有一个庞大的社区,并通过大量示例代码开箱即用地支持许多不同的设备。他们甚至提供示例封装来支持您的特定主板,因此您可以尝试一下,不会有任何损失! http://www.freertos.org/FreeRTOS-for -Cortex-M3-STM32-STM32F100-Discovery.html 。它使您可以访问许多OS ish结构,例如网络API,内存管理和线程,而无需庞大的OS开销和延迟。使用RTOS,您可以创建任务并为其分配优先级,因此您可以成为调度程序,而不再受操作系统的支配。您运行的是操作系统,而不是操作系统运行的(如果这样)。另外,RTOS中提供的构造看起来就像是裸机代码,因此将更容易理解,理解和充分学习。学习诸如Linux或Windows之类的功能强大的OS的基础构建块,这是一个更为简单的世界。如果这个选项听起来不错,我建议您浏览一下FreeRTOS网站上受支持的设备,然后选择您想尝试的设备然后再去尝试。我强烈建议您将其作为一种总体上了解调度和OS结构的方法,因为它尽可能地简单和开源。掌握了RTOS的基础知识之后,专门购买有关Linux的书就不是一个坏主意了。尽管Web上有许多与学习Linux有关的免费资源,但它们通常是矛盾的,并且可能会产生误导。通常,除了学习OS之外,还要大量学习Linux方面的知识,这会使您感到不知所措。从简单开始,可以帮助您避免筋疲力尽,并最大程度地减少您失去感觉的时间。 Linux绝对是一个学习过程,但是与任何学习过程一样,从简单开始,牢记最终目标,制定计划,并按照该计划采取小规模,易于管理的步骤,直到您查找并找到自己想要的位置为止。然后去下一座山!


Although I have implemented many projects in C, I am completely new to operating systems. I tried real time linux on Discovery board (STM32) and got the correct results for blinking LED but I didn't really understand the whole process since I just followed the steps and could not find whole description for each step on the internet.

I want to implement scheduling on real time linux. What is the best way to start? Any sites, books, tutorials available?

Complete RTLinux process description will be appreciated.

Thanks in adv.

解决方案

The transition from "bare metal" to OS based programming is something that I experienced in reverse. I started out a complete software guy, totally into the OS side of things and over time I have moved to the opposite of that (even designing circuits in VHDL!). My advice would be to start simple. Linux is pretty complex, and everywhere you look there are many layers of things all working together to deliver the final product. If you are dead set on a real time linux extension, I'd be happy to suggest https://xenomai.org/ which is a real time extension for linux.

However, to more specifically address your question about implementing scheduling in Linux, you can, but it will be a large amount of work and can be very complicated. The OS uses a completely fair scheduling process ( http://en.wikipedia.org/wiki/Completely_Fair_Scheduler ) and whenever you spin up a thread, it simply gets added to the list to run. This can differ slightly if you implement your code in kernel space as a driver, rely on hardware interrupts, etc., but in general, this is how Linux works. Real time generally means that it has the ability to assign threads one of several different priorities and utilize thread preemption fully at any given time which are concepts that aren't really a part of vanilla Linux. It has some notion of this, but it has limitations that can cause problems when you are looking for real time behavior from Linux.

What may be helpful to you is an RTOS. If you are looking for a full on Real Time Operating System, check out FreeRTOS http://www.freertos.org/ . It has a large community and supports a lot of different devices out of the box with a large amount of example code. They even support your specific board with an example package, so you can give it a shot with nothing to lose! http://www.freertos.org/FreeRTOS-for-Cortex-M3-STM32-STM32F100-Discovery.html . It gives you access to many OS ish constructs like network APIs, memory management, and threading without the overhead and latency of a huge OS. With an RTOS, you create tasks and assign them priorities so you become the scheduler and are no longer at the mercy of the OS. You run the OS, not the OS runs you (if that makes sense). Plus, the constructs offered within an RTOS will feel much like bare metal code and thus will be much easier to follow, understand, and fully learn. It is a more simple world to learn the base building blocks of a full blown OS such as Linux or Windows. If this option sounds good, I would suggest looking through the supported devices on FreeRTOS website and picking one you would like to experiment with and then go for it. I would highly recommend this as a way to learn about scheduling and OS constructs in general as it is as simple as you can get and open source. Once you have the basics of an RTOS down, buying a book about Linux specifically wouldn't be a bad idea. Although there are many free resources on the web related to learning about Linux, they are commonly contradictory, and can be misleading. Pile on learning Linux specific knowledge along with OS in general, and it can feel overwhelming. Starting simpler will help keep you from getting burnt out and minimize the amount of time you spend feeling lost. Linux is definitely a learning process, but like with any learning process, start simple, keep your ultimate goal in mind, make a plan, and take small, manageable steps along that plan until you look up and find yourself exactly where you want to be. Then go tackle the next mountain!

这篇关于用Real Time Linux开始编程的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆