Admin Production ni-theme
Current Publication

Creating Multithreaded Applications

LabWindows/CVI

Multithreading in LabWindows/CVI

While they are often used interchangeably, the terms multitasking, multithreading, and multiprocessing all refer to distinctly different concepts.

  • Multitasking refers to the ability of an OS to switch between tasks quickly to give the appearance of simultaneous execution of those tasks. When running in a preemptive multitasking system, applications can be suspended at any time.
  • Multithreading allows applications to separate their own tasks into individual threads. A thread is a completely independent flow of execution within an application. In a multithreaded program, the OS directs each thread to execute code for a period of time, referred to as a time slice, before switching execution to another thread. The act of stopping execution of one thread and starting execution of another is referred to as a thread switch. The OS typically can perform thread switches quickly enough to give the appearance of concurrent execution of more than one thread at a time.
  • Multiprocessing refers to using multiple processors on one computer. In a symmetric multiprocessing (SMP) system, the OS automatically uses all of the processors in the computer to run any threads that are ready to run. With multiprocessing power, your multithreaded application can run multiple threads simultaneously, finishing more tasks in less time.

Single-threaded applications may experience little performance improvement by switching to a multiprocessor machine. They execute on either one processor or another but never on all processors at once as multithreaded applications do. Single-threaded applications can experience an adverse affect on performance through the overhead of the OS switching the application from one processor to another. To achieve maximum performance from multithreaded OSes and/or multiprocessor machines, an application must be multithreaded.