Example Code

Set Process Priority and Affinity (win API)

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

Coding that exemplifies how to set the priority of an execution.

 

Description

This code consists on how to set process priority and affinity with Windows API calls. Sometimes it is useful to set a higher priority to a specific thread, so we can use this method to do so. Also, we can specify which CPU to use.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code
1. Choose the desired priority
2. Select the affinity
3. Run the VI

 

Additional Information or References

Capture.PNG

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Joel-P
NI Employee (retired)
on

Just a quick note for using this VI: When I initially ran the VI it immediately crashed LabVIEW. This was caused by the Call Library Function Node being configured to use a "c" calling convention. By switching all of the call function library nodes to use the "stdcall (WINAPI)" calling convention, the code ran correctly.

GriffinRU
Member
Member
on

True for LabVIEW versions 2010 and higher.

It is good practice to know exactly which calling conversion to use with given DLL but sometimes you can miss that switch and "c" calling is LabVIEW's default.

Thank you, for your feedback.

-Artur