SetThreadIdealProcessorEx

Sets the ideal processor for the specified thread and optionally retrieves the previous ideal processor.

Syntax

BOOL SetThreadIdealProcessorEx(
         HANDLE hThread,
         PPROCESSOR_NUMBER lpIdealProcessor,
         PPROCESSOR_NUMBER lpPreviousIdealProcessor
)  

Parameters

hThread
Type: HANDLE 

[in] A handle to the thread for which to set the ideal processor. This handle must have been created with the THREAD_SET_INFORMATION access right. For more information, see Thread Security and Access Rights.

lpIdealProcessor
Type: PPROCESSOR_NUMBER 

[in] A pointer to a PROCESSOR_NUMBER structure that specifies the processor number of the desired ideal processor.

lpPreviousIdealProcessor
Type: PPROCESSOR_NUMBER 

[out, optional] A pointer to a PROCESSOR_NUMBER structure to receive the previous ideal processor. This parameter can point to the same memory location as the lpIdealProcessor parameter. This parameter can be NULL if the previous ideal processor is not required.

Return value

Type: BOOL 

If the function succeeds, it returns a nonzero value. If the function fails, it returns zero. To get extended error information, use GetLastError.

Remarks

Specifying a thread ideal processor provides a hint to the scheduler about the preferred processor for a thread. The scheduler runs the thread on the thread’s ideal processor when possible.

Requirements

Header: Declared in processthreadsapi.h.

Library: Use kernelx.lib.