利用实时加速器技术实现Windows操作系统对实时应用程序的支持

概述

如今,越来越多的应用,特别是在工业自动化、医疗技术、数据采集和测量技术等领域,都需要确定性的实时行为。acontis实时加速器技术(RtaccWin)使您能够在Windows下确定性地运行具有硬实时功能的应用程序。这是通过专门为实时应用程序保留一个或多个CPU,为Windows设置适当的参数并利用 acontis内核驱动程序进行精确定时和直接硬件访问来实现的。

软件架构

基于Windows IoT Enterprise的PC可以从acontis的RtaccWin软件中受益,以保证在1毫秒的周期时间中稳定地运行实时应用程序。原则上,还可以实现更快的周期时间。为了实现这一点,至少保留一个CPU(核)专门用于实时应用程序,而其他CPU(核)则分配给标准的Windows应用程序。

RtaccWin 包括一个Windows系统驱动程序,可为整个应用程序提供精确且可调节的时钟。为了确保确定性行为,标准Windows驱动程序通常不用于实时应用程序。相反,RtaccWin中的内核驱动程序允许从 Windows 用户模式直接访问硬件,例如网卡、现场总线卡等,从而降低抖动、显著降低CPU利用率并具有确定性行为。它能在不使用Windows网络堆栈的情况下发送和接收以太网帧,并且在并行使用其他网络接口时不会产生不利影响。

配置工具:RtaccWinConfig

软件配置工具RtaccWinConfig为运行实时应用的Windows系统做准备。首先,它至少隔离了一个CPU(核),这也意味着常规Windows进程和服务不会再使用该CPU(核)。这样,隔离的CPU就能专门用于实时应用程序。

RtaccWinConfig工具的另一个功能是为实时应用分配硬件,这意味着卸载常规的Windows驱动程序,而从Windows的用户空间访问硬件。由acontis内核驱动程序快速、直接地访问已分配的硬件的所有内存区域。

软件开发

开发实时应用的过程类似于标准Windows应用的开发过程。以下是要遵循的步骤:

  • 使用RtaccWinConfig工具进行系统配置
  • 为实时任务创建一个或多个线程
  • 将这些线程分配给先前隔离的CPU(核)
  • 为线程赋予一个非常高的优先级,使它们成为“实时线程”
  • 可选项:通过acontis 的Windows系统驱动程序生成一个稳定而精确的时钟

一个Windows 进程可以包含“非实时线程”和“实时线程”。这两种类型的线程都可以访问全局变量并使用标准同步机制,如事件、临界区、互斥锁和信号量。常用的 Win32 API 也可在“实时线程”中使用。您可以在整个开发过程中使用Microsoft Visual Studio的全部功能。在调试模式下,所有线程都可以访问全部资源。当然,您也可以不考虑实时行为,而是分步执行“实时线程”。

性能

一个稳定、精确、低抖动的时钟对于实时应用是至关重要的,特别是对于每毫秒执行一次的控制循环。理想情况下,应用程序应该每1000微秒精确触发一次,但在实践中可能会出现偏差,导致间隔或长或短。在使用acontis 实时加速器技术时,这些偏差(也称为抖动)可以在 Windows 下显著减少。

RtaccWinConfig 软件工具可以测量具有特定周期时间的一个隔离的CPU核的性能。最大和最小偏差值可以用图形显示。允许的最大抖动取决于应用程序,在通常情况下,可以接受高达周期时间10%的偏差。例如,周期时间为1000微秒时,最小值应不小于900微秒,最大值不应大于1100微秒。

如果没有实时加速器技术,周期时间可能会大幅波动。8小时后,在运行Windows IoT的Minis Forum U820(i5-8279U CPU)上进行了测试,并大量加载烤机测试程序,结果显示有明显的波动。

启用实时加速器技术可以保证时钟的精确度和误差最小,在8小时后的同一系统上进行的测试证明了这一点。

Real-time TCP and UDP communication with lwIP (light weight TCP/IP Stack)

Using Windows it is not possible to guarantee fast network communication via TCP or UDP sockets. As one example it is not possible to use or receive and process a UDP packet every 5 milliseconds. The reason for this is not only the lack of real-time capability of the Windows operating system, but also the lack of real-time capability of the NDIS TCP/IP stack and the network card drivers.

In order to establish a stable, guaranteed, cyclical communication via sockets on Windows, a suitable TCP/IP stack and network driver must therefore be used in addition to the RtaccWin technology.

The widely used open-source software lwIP (light weight IP) is a TCP/IP stack and supports a large variety of protocols, including IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE and contains clients for DHCP, DNS, an SNMP agent and supports AutoIP/APIPA (Zeroconf).

The lwIP TCP/IP stack is operated as a process within the Windows user space on an isolated CPU. The access to the Ethernet interface is realized using acontis Real-time Ethernet drivers. These drivers communicate directly with the hardware without usage of Windows kernel drivers. This enables the real-time threads to communicate quickly and in real time via Ethernet using the TCP and UDP protocols.

Measurements show a significant reduction of jitter

To determine the effective maximum pass-through times as well as the jitter, both for transmitting and receiving a UDP frame, acontis has set up a suitable test system: The network interface of the computer (Minis Forum U820 i5-8279U) with Windows 10 IoT is directly connected to an EtherCAT SubDevice (Beckhoff EK1100) via an Ethernet cable. The transmission rate is 100 Mbit/s and the SubDevice has a very short and uniform throughput delay of approximately one microsecond. In addition to the measurement program, a very high load using by a burn-in test running in parallel was generated on the computer to generate maximum load and stress on the system.

The measurement results clearly show the advantages of the RtaccWin technology in conjunction with the lwIP stack and the acontis Real-time Ethernet drivers:
With the standard Windows setup, it can take more than 26.000 μs in the worst case until the sent UDP frame is received again.
When using RtaccWin but still in combination with standard Windows NDIS stack and drivers, this value drops to 4.896 µs.
If the lwIP stack is used in combination with RtaccWin, the worst-case value is reduced to an impressively low 396 µs.

This enables to realize a stable exchange of cyclical data with a cycle time of one millisecond.

特征

  • 微秒级的快速响应时间
  • 使用基于CPU(核)隔离的实时加速器技术实现硬实时
    • 一个进程中实现实时功能和标准功能使用在同一个隔离的CPU(核)
    • RtaccTimer驱动程序生成精确,稳定的时钟
    • RtaccDevice驱动程序,可以直接访问硬件无需内核驱动程序
  • 合适的配置工具RtaccWinConfig

优势

  • 实时应用程序可以像普通的Windows应用程序一样开发
  • 标准Win32 API也可用于实时线程中
  • 支持Microsoft Visual Studio。方便开发和调试整个实时应用程序。
  • 通过变量进行简单的数据交换。不需要在应用程序的实时和非实时部分之间进行复杂的通信。
  • 操作简单,培训工作量低

系统要求

  • Windows 10 IoT 企业版或 Windows 11 IoT 企业版
  • Windows 11 Professional
  • 四核CPU

More Information