Hello,
How can one set the soft-affinity (and hard-affinity) of a Driver-created
thread to a particular processor ?
Thank you for your help!
Puja
Hello,
How can one set the soft-affinity (and hard-affinity) of a Driver-created
thread to a particular processor ?
Thank you for your help!
Puja
Use ZwSetInformationThread with THREADINFOCLASS set to ThreadAffinityMask.
The affinity mask ought to be a ULONG, but it appears to be undocumented in
the DDK. Each bit corresponds to the processor to which you want this thread
bound. You can set more than one bit. Who knows what happens if you set only
bits for processors that don’t exist. There is most likely some Nt
equivalent that you could look up in Undocumented Windows NT to confirm the
Zw parameters. Thereis probably a Win32 equivalent too.
That’s hard affinity. Soft affinity as far as I know is not programmable. It
is a function of the run time behavior of the thread and some screwball
algorithm in the dispatcher. It should be ignored.
Mark Roddy
Windows 2000/NT Consultant
Hollis Technology Solutions
www.hollistech.com
The function ZwSetInformationThread is partially documented. You can use the
following lines of code in a device driver to set the thread affinity:
KAFFINITY threadAffinityMask;
threadAffinityMask = KeNumberProcessors & ( 1<< TargetProcessorNumber)
; // TargetProcessorNumber is a zero based number
status = ZwSetInformationThread((HANDLE)-2, //current thread handle
ThreadAffinityMask,
&threadAffinityMask,
sizeof(KAFFINITY));
-Eliyas
-----Original Message-----
From: xxxxx@usa.net [mailto:xxxxx@usa.net]
Sent: Wednesday, April 19, 2000 7:00 PM
To: NT Developers Interest List
Subject: [ntdev] Soft Affinity of Thread
Hello,
How can one set the soft-affinity (and hard-affinity) of a Driver-created
thread to a particular processor ?
Thank you for your help!
Puja
You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)
Hello,
Maybe I’m missing something really big here, but I donot understand the
code snippet:
[By my calculation, threadAffinityMask is always 0 if I use the code
snippet given here]
Appreciate the clarification.
Thanks
Puja
Hello,
Maybe I’m missing something really big here, but I donot understand the
code snippet in the post below:
[By my calculation, threadAffinityMask is always 0 if I use the code
snippet given here]
Appreciate the clarification.
Thanks
Puja
On 04/21/00, “Eliyas Yakub ” wrote:
> The function ZwSetInformationThread is partially documented. You can use the
> following lines of code in a device driver to set the thread affinity:
>
> KAFFINITY threadAffinityMask;
> threadAffinityMask = KeNumberProcessors & ( 1<< TargetProcessorNumber)
> ; // TargetProcessorNumber is a zero based number
> status = ZwSetInformationThread((HANDLE)-2, //current thread handle
> ThreadAffinityMask,
> &threadAffinityMask,
> sizeof(KAFFINITY));
>
> -Eliyas
>
> -----Original Message-----
> From: xxxxx@usa.net [mailto:xxxxx@usa.net]
> Sent: Wednesday, April 19, 2000 7:00 PM
> To: NT Developers Interest List
> Subject: [ntdev] Soft Affinity of Thread
>
>
> Hello,
>
> How can one set the soft-affinity (and hard-affinity) of a Driver-created
> thread to a particular processor ?
>
> Thank you for your help!
> Puja
>
> —
> You are currently subscribed to ntdev as: xxxxx@microsoft.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
KAFFINITY
KeSetAffinityThread (
IN PKTHREAD Thread,
IN KAFFINITY Affinity
)
That’s hard affinity. Soft affinity as far as I know is not programmable.
It
CCHAR
KeSetIdealProcessorThread (
IN PKTHREAD Thread,
IN CCHAR Processor
)
Max