Most computers have only one processor, so tasks execute one at a time. Computers achieve multitasking by running one application for a short amount of time and then running other applications for short amounts of time. As long as the amount of processor time allocated for each application is small enough, computers appear to have multiple applications running simultaneously.
Multithreading is when you apply the concept of multitasking to a single application by breaking it into smaller tasks that execute for short amounts of time in different execution system threads. A thread is a completely independent flow of execution for an application within the execution system. Multithreaded applications maximize the efficiency of the processor because the processor does not sit idle if there are other threads ready to run. Any application that reads and writes from a file, performs I/O, or polls the user interface for activity can benefit from multithreading because it can use the processor to run other tasks during breaks in these activities.
The real-time operating system (RTOS) on RT targets and the RTX subsystem use a combination of round robin and preemptive scheduling to execute threads in the execution system. Round robin scheduling applies to threads of equal priority. Equal shares of processor time are allocated among equal priority threads. For example, each normal priority thread is allotted 10 ms to run. The processor executes all the tasks it can in 10 ms and whatever is incomplete at the end of that period must wait to complete during the next allocation of time. Conversely, preemptive scheduling means that any higher priority thread that needs to execute immediately pauses execution of all lower priority threads and begins to execute. A time-critical priority thread is the highest priority and preempts all priorities.
Timed Loop create a thread that runs below the time-critical priority and above high priority. You can then customize the priority level of different Timed Loops within a VI.
Deterministic applications depend on time-critical tasks to complete on time, every time. Therefore, time-critical tasks need enough processor resources to ensure their completion.
Separate time-critical tasks from all other tasks to ensure time-critical tasks receive enough processor resources. For example, if a control application acquires data at regular intervals and stores the data on disk, you must handle the timing and control of the data acquisition deterministically. However, storing the data on disk is inherently a non-deterministic task because file I/O operations have unpredictable response times that depend on the hardware and the availability of the hardware resource. You can use Timed Loops (ETS, VxWorks) or VIs with different priorities to control the execution and timing of time-critical tasks.