Hard and soft Real-time system

A system is said to be real-time if the total correctness of an operation depends not only upon its logical correctness, but also upon the time in which it is performed. The classical conception is that in a hard or immediate real-time system, the completion of an operation after its deadline is considered useless - ultimately, this may lead to a critical failure of the complete system. A soft real-time system on the other hand will tolerate such lateness, and may respond with decreased service quality (e.g., dropping frames while displaying a video).


Hard real-time systems are typically found interacting at a low level with physical hardware, in embedded systems. For example, a car engine control system is a hard real-time system because a delayed signal may cause engine failure or damage. Other examples of hard real-time embedded systems include medical systems such as heart pacemakers and industrial process controllers.


Hard real-time systems are used when it is imperative that an event is reacted to within a strict deadline. Usually such strong guarantees are required of systems for which not reacting in a certain window of time would cause great loss in some manner, especially physically damaging the surroundings or threatening human lives (although the strict definition is simply that missing the deadline constitutes failure of the system). Systems that always have hard real-time constraints (due to the potentially severe outcome of missing a deadline) include nuclear power stations and car airbags. In the context of multitasking systems the scheduling policy is normally priority driven pre-emptive schedulers. Other scheduling algorithms include Earliest Deadline First, which, ignoring the overhead of context switching, is sufficient for system loads of less than 100%.[citation needed]


New overlay scheduling systems, such as an Adaptive Partition Scheduler assist in managing large systems with a mixture of hard real-time and non real-time applications.



Soft real-time systems are typically those used where there is some issue of concurrent access and the need to keep a number of connected systems up to date with changing situations. Example: the software that maintains and updates the flight plans for commercial airliners. These can operate to a latency of seconds. Live audio-video systems are also usually soft real-time; violation of constraints results in degraded quality, but the system can continue to operate.


It is important to note that hard versus soft real-time does not necessarily relate to the length of time available. A machine may overheat if a processor does not turn on cooling within 15 minutes (hard real-time). On the other hand, a network interface card may lose buffered data if it is not read within a fraction of a second, but the data can be resent over the network (soft real-time), without major adverse consequences.


硬实时, 顾名思义是由硬件、即计算机主机板上的硬件 - 集成电路,如CPU, BIOS等来进行实时控制。也就是说将CPU的运算周期(CPU cycle)按照事先设定的标准,如平均分配(所谓的Time slice)、或按某些硬件优先权分配,等等,来防止某个硬件夺去整个系统的反应时间, 让各个外接部件, 特别是输入输出设备等, 能够得到系统的及时反馈,也就是说,某个外接部件在多长的时间里能够得到系统的反馈,得到CPU完成计算的时间,是可以得到保证的, 这也就是所谓的deterministic real time。 其实,真正的实时系统不仅需要硬件的支持,还需要专门的实时操作系统, 所以一般这种都是专门的设备,如工业自动化控制,军用电子设备等。它们的操作系统都是专门做的。 


软实时指的是在对非实时的操作系统,比如桌面计算机操作系统, 如Windows, 进行某些改动,来达到近乎实时的效果, 但是严格来说还不是真正的实时, 只是接近实时而已。它的做法是用一个专门的软件部件,代替桌面计算机操作系统中的进行控制的功能,如 process control 和 kernel,以达到一个接近于能够准时得到系统反馈和完成计算的反应速度。 我所知道的,有几个小公司成功地开发了加在Windows XP Embedded (XPE)上的软实时附加件,使得开发商能够使用XPE来达到近乎软实的效果。 在欧美市场上, 就已经有开发商用这个方法来开发制造"软实"的赌博游戏机、医疗器械、自动化控制设备, 等等。


#######################

Real Time OS (Real Time Operating System)


实时操作系统

什么东西一旦弄上实时两个字就是对响应时间有严格的要求。实时操作系统贵在实时,要求在规定的时间内完成某种操作。主要用在工业控制中,实时操作系统中一般任务数是固定的,有硬实时和软实时之分,硬实时要求在规定的时间内必须完成操作,这是在操作系统设计时保证的;软实时则没有那么严,只要按照任务的优先级,尽可能快地完成操作即可。我们通常使用的操作系统在经过一定改变之后就可以变成实时操作系统。

实时操作系统是保证在一定时间限制内完成特定功能的操作系统。例如,可以为确保生产线上的机器人能获取某个物体而设计一个操作系统。在“硬”实时操作系统中,如果不能在允许时间内完成使物体可达的计算,操作系统将因错误结束。在“软”实时操作系统中,生产线仍然能继续工作,但产品的输出会因产品不能在允许时间内到达而减慢,这使机器人有短暂的不生产现象。一些实时操作系统是为特定的应用设计的,另一些是通用的。一些通用目的的操作系统称自己为实时操作系统。但某种程度上,大部分通用目的的操作系统,如微软的Windows NT或IBM的OS/390有实时系统的特征。这就是说,即使一个操作系统不是严格的实时系统,它们也能解决一部分实时应用问题。

通常,实时操作系统必须有以下特征:

1)多任务;

2)有线程优先级

3)多种中断级别

小的嵌入式操作系统经常需要实时操作系统。内核要满足实时操作系统的要求。但其它部件,如设备驱动程序也是需要的,因此,一个实时操作系统常比内核大。


[B]软实时系统和硬实时系统[/B]

实时系统对逻辑和时序的要求非常严格,如果逻辑和时序出现偏差将会引起严重后果。实时系统有两种类型:软实时系统和硬实时系统。
软实时系统仅要求事件响应是实时的,并不要求限定某一任务必须在多长时间内完成;而在硬实时系统中,不仅要求任务响应要实时,而且要求在规定的时间内完成事件的处理。通常,大多数实时系统是两者的结合。

事实上,没有一个绝对的数字可以说明什么是硬实时,什么是软实时。它们之间的界限是十分模糊的。这与选择什么样的CPU,它的主频、内存等参数有一定的关系[1]。另外,因为应用的场合对系统实时性能要求的不同而有不同的定义。因此,在现有的固定的软、硬件平台上,如何测试并找出决定系统实时性能的关键参数,并给出优化的措施和试验数据,就成为一个具有普遍意义并且值得深入探讨的课题。本文就是基于此目的进行讨论的。

因为采用实时操作系统的意义就在于能够及时处理各种突发的事件,即处理各种中断,因而衡量嵌入式实时操作系统的最主要、最具有代表性的性能指标参数无疑应该是中断响应时间了。中断响应时间通常被定义为:

  中断响应时间=中断延迟时间+保存CPU状态的时间+该内核的ISR进入函数的执行时间[2]。

  中断延迟时间=MAX(关中断的最长时间,最长指令时间) + 开始执行ISR的第一条指令的时间[2]。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值