Soft affinity

Is there a way to set the soft affinity for a thread in the system process?
I would like to load balance several worker threads for better performance.

I was thinking that seting the affinity for the thread to one processor,
then setting it back the way it was. My theory being that the soft affinity
will change to the processor I selected and then stay that way when I change
the affinity back.

Can anyone confirm this theory, or offer a better way to do this? Also, can
anyone tell me where I can find the “soft affinity” for a particular thread?

Thanks,
Kurt

Kurt Godwin wrote:

Is there a way to set the soft affinity for a thread in the system process?
I would like to load balance several worker threads for better performance.

I was thinking that seting the affinity for the thread to one processor,
then setting it back the way it was. My theory being that the soft affinity
will change to the processor I selected and then stay that way when I change
the affinity back.

Can anyone confirm this theory, or offer a better way to do this? Also, can
anyone tell me where I can find the “soft affinity” for a particular thread?

Thanks,
Kurt

Kurt,
I haven’t tried this with drivers but I have no faith in NT’s ability to
do this (at least up to 2000).

I have noticed many times that when running a single CPU-bound thread on
a dual processor machine, rather than keeping that thread on one of the
CPUs (hence keeping the cache on that CPU full of relevant data) it
switches it between the two CPUs giving them both half the load - and
presumably thrashing the caches.

I can’t retry on XP because my dual blew up!

Andy.

> switches it between the two CPUs giving them both half the load -
and

presumably thrashing the caches.

I suspect this is done on quantum ends only, which are rare enough
(quantums are long) to really slow down due to cache thrash.
It would be interesting to test with a thread which does something
like - count to 10000, then Sleep(1). There will be no quantum ends in
this case.

Max

Maxim S. Shatskih wrote:

>switches it between the two CPUs giving them both half the load -
>
and

>presumably thrashing the caches.
>

I suspect this is done on quantum ends only, which are rare enough
(quantums are long) to really slow down due to cache thrash.
It would be interesting to test with a thread which does something
like - count to 10000, then Sleep(1). There will be no quantum ends in
this case.

Max

Someone want to try this (as I said, I have no dual any more!) but surely sleep(0)?

However why would it be done on quantum ends either?

Andy