Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Instrumentation Newsletter
NI Supported: Yes
Publish Date: Mar 6, 2008


Feedback


Yes No

Related Links - Developer Zone

Related Links - Products and Services

Will Multicore Hardware Leave Your Real-Time Software Behind?

2 ratings | 4.00 out of 5
Read in | Print

The advent of multicore processors presents new development challenges but also creates opportunities to design real-time systems that can do more than ever before.  To fully take advantage of the performance potential of multicore processors, all layers of the real-time software stack must be “multicore-ready.”


[+] Enlarge Image

 

Figure 1. With the LabVIEW 8.5 Real-Time and LabWindows/CVI 8.5 Real-Time modules, you now have the flexibility to assign application tasks to specific CPU cores on the latest PXI and PC multicore hardware.  

 

Keys to Being Multicore-Ready

As companies migrate applications based on a single-processing software stack to one based on a multiprocessing model, they must verify that each layer of the stack is multicore-ready. This process can consume a great deal of time and resources. One advantage of the NI LabVIEW 8.5 Real-Time Module and the LabWindows™/CVI 8.5 Real-Time Module is that their software stacks meet all the requirements for multicore readiness, including a programming language equipped to create multithreaded applications, access to thread-safe libraries and drivers, the ability to maintain determinism across multiple cores, and integrated debugging tools.  

 

Many bottlenecks in parallel applications occur because user interface, analysis, or hardware library calls are not thread-safe. Non-reentrant code might still function properly, but it cannot execute in parallel on a multicore processor, and it can become a shared resource, leading to performance problems. LabVIEW and LabWindows/CVI overcome these pitfalls with reentrant analysis libraries and I/O drivers, such as NI-DAQmx.    

 

 


[+] Enlarge Image

 

 

Table 1 . The real-time software stack consists of a development tool, libraries, device drivers,

and a real-time operating system.  

 

Controlling the Processor Affinity of Real-Time Tasks

Multithreading and multitasking support in a real-time operating system (RTOS) provides the basis for taking advantage of multicore performance in real time. An RTOS that implements a symmetric multiprocessing (SMP) model not only provides the flexibility to assign tasks to specific cores, but it also offers built-in logic to load-balance tasks across multiple cores.  

 

Specifically, SMP is an OS-supported characteristic you can use to easily move between processors to efficiently balance workload. Most general-purpose OSs such as Windows, Linux®, and Mac OS support SMP. However, RTOS support for SMP is not trivial because the deterministic behavior of an RTOS must be preserved to meet hard real-time timing constraints while distributing tasks across different processors at the same time. With the LabVIEW Real-Time OS for ETS targets, one of the few RTOSs that supports SMP, you now can take full advantage of the latest multicore hardware – such as the NI PXIe-8130 RT, the first PXI Express real-time controller. Using the NI PXIe-8130 RT and the LabVIEW Real-Time Module, you can increase performance and determinism for large real-time test and control applications using the available dual cores on the AMD processor.  

 

To further increase the performance and reliability of a real-time system, you can easily assign timed loops or threads to specific processor cores. You can dedicate one core of a processor to execute a time-critical control loop and isolate it from less important tasks that run on different cores.    

 

 


[+] Enlarge Image

 

Figure 2. The Real-Time Execution Trace Toolkit 2.0 clearly highlights the thread-safe behavior of the NI-DAQmx API in a multicore application.

 

Debugging Multicore Real-Time Systems

Finally, debugging tools provide insight into how code is executing on multicore hardware, making them a critical piece of the software stack. In multicore applications, debugging poses a unique challenge. You must not only trace the execution of two pieces of code at once, but you also need to determine which piece of code is running on which processor. Also, if you frequently program multithreaded applications, you will eventually deal with thread-swapping and starvation issues, which need to be identified during the debugging process.

 

According to a survey conducted by Virtutech of Embedded Systems Conference 2007 attendees, 59 percent of respondents said their debugging tools did not support multicore or multiprocessor development. On the contrary, both LabVIEW and LabWindows/CVI contain several features that greatly simplify debugging multicore applications. Specifically, in LabVIEW, you can use execution highlighting, probes, and breakpoints to debug at the VI level, while in LabWindows/CVI, you can use the Thread View, Watch Window, and Variable Window to visually monitor functions as they are executing on different cores.  

 

In addition, system tracing tools can ease the transition to multicore processors by simplifying troubleshooting and design optimization. Whether you explicitly define threads using APIs, such as the LabWindows/CVI Multithreading Library, or use LabVIEW to automatically generate threads for parallel sections of code, the Real-Time Execution Trace Toolkit 2.0  provides a visual representation of both VI and thread execution on single-core or multicore systems. With the trace results, you can find hot spots in your code and detect undesirable behavior – such as resource contention, thread starvation, memory allocation, and priority inversion – while verifying expected timing behavior and monitoring CPU usage.

 

– Wendy Logan

Wendy Logan is the product engineer for LabWindows/CVI. She holds a bachelor’s degree in computer science from Rice University.

 

– Jeff Meisel

Jeff Meisel is the product manager for the LabVIEW Real-Time Module. He holds a bachelor’s degree in computer engineering from Kansas State University.  

 

Learn more about developing high-performance real-time systems with multicore technology.

 

The mark LabWindows is used under a license from Microsoft Corporation.

 

This article first appeared in the Q4 2007 issue of Instrumentation Newsletter.

2 ratings | 4.00 out of 5
Read in | Print

Reader Comments | Submit a comment »

 

Legal
This material is protected under the copyright laws of the U.S. and other countries and any uses not in conformity with the copyright laws are prohibited, including but not limited to reproduction, DOWNLOADING, duplication, adaptation and transmission or broadcast by any media, devices or processes.