LabWindows/CVI

Content Type
Programming Language
Current manual

Setting the Preferred Processor for a Thread

Setting the Preferred Processor for a Thread

You can use the following Windows SDK functions if you want to set a processor for threads in your program.

  • Call SetThreadIdealProcessor if you need to specify the processor on which to run a particular thread.
  • Call SetProcessAffinityMask to specify the processors on which the threads in your program are allowed to run.
  • Call SetThreadAffinityMask to specify processors on which a particular thread in your program is allowed to run.
Note Note  
  • The SetThreadIdealProcessor and SetThreadAffinityMask functions take a thread handle as their first parameter. You can call the LabWindows/CVI Utility Library CmtGetThreadPoolFunctionAttribute function with the ATTR_TP_FUNCTION_THREAD_HANDLE attribute to obtain the handle of a thread pool thread.
  • The second parameter to SetThreadIdealProcessor is the zero-based index of the processor. You can call the LabWindows/CVI Utility Library CmtGetNumProcessors function to programmatically determine the number of processors in the machine that is running your program.
  • The mask you pass to SetThreadAffinityMask must be a subset of the mask you pass to SetProcessAffinityMask.
  • These functions have an effect only when your program runs on a multiprocessor machine.
Was this information helpful?