SetThreadAffinityMask Problem to schedule a thread on a specific CPU

A

alex.buisson

Hello,

I have a quite strange behavior with the SetThreadAffinityMask
function.

I am executing a C# program that loads a C language Dll. It is this
Dll that uses SetThreadAffinityMask().

The first time the Dll is called, the behavior of
SetThreadAffinityMask is correct. I mean, I can make several calls to
SetThreadAffinityMask() and see the previous affinity mask that
switches from the processor 1 to the processor 2.

Then I make a call to the C# function GetProcessByName().

After this call, if I use the Dll again, then the
SetThreadAffinityMask does not work correctly. I try to set the thread
on the first processor which is part of the processAffinityMask but
the SetThreadAffinityMask always returns me a previous affinityMask
equal to the second processor.

It is like it was ok (return code different from 0) but, visibly there
is something wrong and the affinity is not changed. So, what is the
origin of this problem? What happens in this GetProcessByName method
in order to change the behavior of SetThreadAffinityMask function?

I am under windows XP and the symptom is the same in case of a true
separate processors or a dual core.

Any help would be welcome
Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top