是什么使内核/OS实时? [英] What makes a kernel/OS real-time?

查看:92
本文介绍了是什么使内核/OS实时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读文章,但我的问题是一般性的,我在考虑以下方面:

I was reading this article, but my question is on a generic level, I was thinking along the following lines:

  1. 是否可以仅由于内核具有实时调度程序而将其称为实时内核?换句话说,如果我有一个Linux内核,并且如果将默认调度程序从O(1)CFS更改为real time scheduler,它将变成RTOS吗?
  2. 是否需要硬件的任何支持?通常,我已经看到具有RTOS的嵌入式设备(例如VxWorks,QNX),这些设备是否有任何特殊规定/硬件来支持它们?我知道RTOS进程的运行时间是确定的,但随后可以使用longjump/setjump在确定的时间内获取输出.
  1. Can a kernel be called real time just because it has a real time scheduler? Or in other words, say I have a linux kernel, and if I change the default scheduler from O(1) or CFS to a real time scheduler, will it become an RTOS?
  2. Does it require any support from the hardware? Generally I have seen embedded devices having an RTOS (eg VxWorks, QNX), do these have any special provisions/hw to support them? I know RTOS process's running time is deterministic, but then one can use longjump/setjump to get the output in determined time.

我真的很感谢您的投入/见解,如果我对某件事有误,请纠正我.

I'd really appreciate some input/insight on it, if I am wrong about something, please correct me.

推荐答案

进行了一些研究之后,与人(Jamie Hanrahan,Juha Aaltonen @linkedIn Group-设备驱动程序专家)进行了交谈,当然还有@Jim Garrison的输入,我可以得出结论:

After doing some research, talking to poeple (Jamie Hanrahan, Juha Aaltonen @linkedIn Group - Device Driver Experts) and ofcourse the input from @Jim Garrison, this what I can conclude:

Jamie Hanrahan 的话-

什么使内核实时?
实时操作系统的准非-

What makes a kernel real time?
The sine qua non of a real time OS -

  • 能够确保外部中断与中断处理程序启动之间的最大延迟时间.

请注意,最大等待时间不必特别短(例如微秒),您可以拥有一个实时操作系统,以保证绝对最大等待时间为137毫秒.

Note that the maximum latency need not be particularly short (e.g. microseconds), you could have a real time OS that guaranteed an absolute maximum latency of 137 milliseconds.

实时调度程序是一种提供(对开发人员)完全可预测的(对开发人员而言)线程调度行为-下一步运行哪个线程".

A real time scheduler is one that offers completely predictable (to the developer) behavior of thread scheduling - "which thread runs next".

这通常与为响应中断而保证的最大等待时间问题分开(因为中断处理程序不一定像普通线程一样进行调度),但通常有必要实现实时应用程序.实时操作系统中的调度程序通常实现大量的优先级.并且它们几乎总是实现优先级继承,以避免优先级反转的情况.

This is generally separate from the issue of a guaranteed maximum latency to responding to an interrupt (since interrupt handlers are not necessarily scheduled like ordinary threads) but it is often necessary to implement a real-time application. Schedulers in real-time OSs generally implement a large number of priority levels. And they almost always implement priority inheritance, to avoid priority inversion situations.

因此,保证中断的延迟和线程调度的可预测性是一件好事,然后为什么不使每个OS都实时呢?

  • 因为适用于一般用途的操作系统(服务器和/或台式机)需要具有通常与实时延迟保证不一致的特性.

  • Because an OS suited for general purpose use (servers and/or desktops) needs to have characteristics that are generally at odds with real-time latency guarantees.

例如,实时调度程序应具有完全可预测的行为.这意味着,除其他外,开发人员为各种任务分配的优先级应由OS独自处理. 这可能意味着某些低优先级的任务最终会长时间饿死.但是RT OS必须耸耸肩说开发人员想要的".请注意,要获得正确的行为,RT系统开发人员必须非常担心任务优先级和CPU亲和力等问题.

For example, a real-time scheduler should have completely predictable behavior. That means, among other things, that whatever priorities have been assigned to the various tasks by the developer should be left alone by the OS. This might mean that some low-priority tasks end up being starved for long periods of time. But the RT OS has to shrug and say "that's what the dev wanted." Note that to get the correct behavior, the RT system developer has to worry a lot about things like task priorities and CPU affinities.

通用操作系统正好相反.您希望能够将应用程序和服务(几乎总是由许多不同的供应商编写的东西)放到上面(而不是像大多数R-T系统那样是一个紧密集成的系统),并获得良好的性能.可能不是绝对最佳的性能,而是良好的.

A general-purpose OS is just the opposite. You want to be able to just throw apps and services on it, almost always things written by many different vendors (instead of being one tightly integrated system as in most R-T systems), and get good performance. Perhaps not the absolute best possible performance, but good.

请注意,良好的性能"不仅可以通过中断延迟来衡量.特别是,您希望CPU和其他资源分配通常被描述为公平",而用户,管理员甚至应用程序开发人员都不必担心线程优先级,CPU亲和力和NUMA节点之类的事情.一个工作可能比另一个工作更重要,但是在通用操作系统中,这并不意味着第二个工作根本就不会获得任何资源.

Note that "good performance" is not just measured in interrupt latency. In particular, you want CPU and other resource allocations that are often described as "fair", without the user or admin or even the app developers having to worry much if at all about things like thread priorities and CPU affinities and NUMA nodes. One job might be more important than another, but in a general-purpose OS, that doesn't mean that the second job should get no resources at all.

因此,通用操作系统通常会在优先级相同的线程之间实现时间分片,并且可以根据其过去的行为来调整线程的优先级(例如,CPU hog的优先级可能会降低; I/O绑定线程可能会增加其优先级,因此可以使I/O设备正常工作; CPU匮乏的线程可能会提高其优先级,因此有时会占用一点CPU时间.

So the general purpose OS will usually implement time-slicing among threads of equal priority, and it may adjust the priorities of threads according to their past behavior (e.g. a CPU hog might have its priority reduced; an I/O bound thread might have its priority increased, so it can keep the I/O devices working; a CPU-starved thread might have its priority boosted so it can get a little bit of CPU time now and then).

是否可以仅因为它具有实时调度程序而将其称为实时内核?

  • 不,RT调度程序是RT操作系统的必要组成部分,但是您在OS的其他部分也需要可预测的行为.

它需要硬件的任何支持吗?

  • 通常,硬件越简单,其行为就越可预测.因此,PCI-E的可预测性不如PCI,PCI的可预测性不如ISA等.中断延迟,但如今使用商用硬件可以满足很多R-T要求.

这篇关于是什么使内核/OS实时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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