Nikkei Electronics Asia -- December 2006
Monthly Special
Virtual Machine Technology to Enable Real-Time Embedded Applications

E-Mail Article
Tweet This
Digg This
Share this with friends on Facebook
Buzz Up!
Dec 6, 2006 18:19 Nikkei Electronics Asia

Windows applications have continued to advance in providing powerful instrumentation development and operator interface systems, but a limitation on system performance has traditionally resulted from the Windows-based operating environment's lack of ability to keep up with real-time events. Windows was designed as a human-directed operating system, initially for use in an office environment, but over the last decade it has been adopted by industrial applications as an excellent platform for hosting human-machine interfaces.

This poses both an opportunity and a challenge for industrial embedded system designers faced with the task of designing systems that must support attractive, useful human interfaces, while at the same time provide quick responsiveness to real-time events such as receiving data streams from machine vision systems or responding to feedback signals from robotic motion systems. To meet these competing requirements, they would like to have the ability to run multiple operating environments simultaneously on the same system. Without such a solution, they often need to develop separate hardware subsystems for real-time and human interface processing, at increased cost to the customer.

Using virtual machine technology, a single-computer, dual-OS system can be implemented. Such a system resolves the bottleneck associated with the coordination of Windows applications and real-time processes in a single CPU system, and significantly reduces manufacturing cost and complexity compared to dual computer, dual OS solutions. The single computer, dual OS approach also enables the use of a single set of development tools for implementing both the real-time and human-directed functions, cutting design costs and effort that would otherwise be spent on a second set of engineering tools and staff.

INtime RTOS
An example of a fully-featured real-time operating system (RTOS) that coordinates Windows with real-time processing is INtime (see Fig). INtime works by creating a virtual machine environment to separate the real-time and Windows components of an application. Applications written for the INtime RTOS execute with guaranteed determinism as fully-protected user-mode processes in parallel with the Microsoft Windows operating system on standard PC hardware. 

One of the Windows application environments that benefits from combination with the INtime RTOS on a single platform is National Instruments' LabVIEW Embedded environment. Using LabVIEW Embedded on INtime, instrumentation application developers can implement Virtual Instruments as they are accustomed, with the underlying control, data acquisition, and processing functions operating in a robust, real-time environment that can update instrument display parameters and close control loops as often as once every 50us.

Typically, applications with cycle times of 1ms or slower are served well by a uni-processor/multi-OS arrangement and have been deployed on the current crop of desktop and industrial motherboard platforms (Pentium 4 class processors running at 1-3GHz). However, some applications demand faster cycle times. For these applications the solution is to use a new dual-core processor chip.

Dual-core processors easily support two operating systems at higher performance levels by dedicating one CPU to the RTOS. The CPU instruction cycles of the core dedicated to the RTOS are available 100% of the time to the real-time applications. The CPU cycles of the remaining core become the exclusive property of the Windows virtual machine. Contention for key CPU resources such as pipelines, caches, and the FPU are avoided. Coordination between the two processor cores is accomplished by using built-in interprocessor communication mechanisms, eliminating context switches. In this scenario, real-time interrupt latencies are reduced by an order of magnitude, from 10-30us down to 1-3us, enabling loop cycle times in the 50-200us range to operate with high precision and accuracy.

The result is an order of magnitude improvement in the quality and bandwidth of control algorithms that can be deployed on a real-time Windows platform.

Virtual Machine Approach
The virtual machine approach to combining real-time task processing and Windows applications in the same system is quite different from approaches that install a real-time kernel in the form of a Windows device driver or subsystem. The device driver and subsystem models force real-time applications to operate as part of the Windows kernel. Kernel mode code has privileged access to the entire memory space, including the Windows kernel and other device drivers; it lacks address isolation and memory protection. A real-time thread running on such a system can easily overwrite other processes: both real-time and Windows processes. Because such programming errors are difficult to detect in kernel mode, and can result in spurious but critical failures, achieving reliable operation through this method often requires extensive testing and debugging. Many such errors are not detectable until the system has been deployed in the field. Creating a complex, multi-threaded, real-time application to run inside the Windows kernel is counterproductive to building reliable, safe, and dependable real-time applications.

To insure efficient implementation of real-time threads, virtual machine architecture has been designed to support direct access to I/O and memory, a fixed priority scheduling system with priority-inversion protection, and simplified interrupt-handling services. Designers can then create and deploy sophisticated real-time applications without having to write complex and cumbersome device drivers for access to real-time hardware, simplifying development and debugging of control and data acquisition algorithms.

Applications hosted on the INtime RTOS, such as LabVIEW Embedded's real-time data acquisition components, execute with guaranteed determinism as fully-protected user-mode processes in concurrence with the Microsoft Windows operating system on standard PC hardware. Because real-time application code executes in user-mode the INtime environment is immune to application faults that crash kernel-mode driver solutions

Dual Systems
As with single CPU, dual OS systems, dual-core dual OS implementations can also benefit from the use of a single development environment. For Windows-based applications, the development tool of choice is Microsoft Visual Studio, a multi-language development environment that can be used to build and maintain a broad range of applications. Visual Studio 2003 and 2005 include hooks for third-party plug-ins, providing a means to extend the integrated development environment (IDE). By utilizing these hooks, third-party development tool providers can enhance the Visual Studio IDE to include features for tasks that go beyond the development of standard Windows applications, such as the creation of real-time embedded Windows applications, uniting the two parts of a Windows real-time solution under a single IDE.

Because the LabVIEW system was designed to integrate the real-time and Windows environments, it is not necessary to have a separate development workstation. The target system is also the development system. Standard Windows development tools can be used for both the Windows part and the real-time part of an application. A single compiler, linker, editor, and debugger serves both virtual machines.

When applying Windows to time-critical instrumentation applications, incorporating a real-time operating system into the architecture is often necessary to satisfy the requirements for accurate and repeatable data acquisition and control. An RTOS that shares the CPU with Windows allows embedded Windows applications to take full advantage of the Windows standard user interface, network capabilities, development tools, and off-the-shelf software and still deliver the performance required by critical, hard real-time tasks. The key to getting Windows and the RTOS to cooperate effectively is to use an RTOS that employs a virtual machine approach.

by Kim Hartman,
VP Marketing & Sales,
TenAsys Corp