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

Creating Multithreaded Applications

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

Even though the benefits of multithreading, or multi-core programming, are numerous, many people choose not to exploit this powerful technology because it can be difficult to implement. However, several development tools provide mechanisms to create and debug multithreaded applications.

Text-Based Programming Approaches

In Visual C/C++ and Borland C++, you can use built-in multithreading libraries to create and manage threads. However, in text-based languages, where code typically runs sequentially, it often can be difficult to visualize how various sections of code run in parallel. Because the syntax of the language is sequential, the code is basically run line by line. And, because threads within a single program usually share data, communication among threads to coordinate data and resources is so critical that you must implement it carefully to avoid incorrect behavior when running in parallel. You must write extra code to manage these threads. Thus, the process of converting a single-threaded application into a multithreaded one can be time consuming and error prone.

Text-based programming languages must incorporate special synchronization functions when sharing resources such as memory. If you do not implement multithreading properly in the application, you may experience unexpected behavior. Conflicts can occur when multiple threads request shared resources simultaneously or share data space in memory. Current tools, such as multithread-aware debuggers, help a great deal, but in most cases you must carefully keep track of the source code to prevent conflicts. In addition, you must often adapt your code to accommodate parallel programming.

Graphical Programming Approaches

A graphical programming paradigm lends itself to the development of parallel code execution. Because it is much easier to visualize the parallel execution of code in a dataflow environment, where two icons or two block diagrams reside side by side, graphical programming is ideal for developing multithreaded applications. However, the same problems with communication among threads can arise unless LabVIEW manages the threads for you.


Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit