I've written a DLL that creates a driver service, starts it and then uses IODeviceControl to read some information from the driver. I am trying to use either SetThreadAffinityMask or GetProcessAffinityMask/Set
ProcessAff
inityMask to set the process/thread affinity to each core in the system, one at a time, in order to read a CPU specific MSR (via the device driver). This is done in a loop, where the loop cycles for each cpu detected.
Psuedo-code that illustrates what I am trying to do:
for ( i = 0 ; i < numProcessorsDetected; i++ ) {
SetProcessAffinityMask(); //set process to run only on the CPU 0, then CPU 1, then CPU2, then...
IODeviceControl(); //get some information from my driver
//do something with data return from IODeviceControl call
}
SetProcessAffinityMask(); // back to all CPUs running
It appears that the mask is being set correctly but the driver is not executing code in the context of my calling user mode DLL. Is this a limitation of the Window's IO subsystem? Am I going to need to set affinity in kernel mode to ensure that the assembly code utilitized in the driver routine is actually running on the CPU that I need it to run on?
I am really confused on where to go next. I really don't want to have to mess with my driver and create DPCs just to do this. I would much rather do the coding in user mode as the driver is working great right now.
I can't find information ANYWHERE on this subject. Anything anyone can add would be extremely helpful.
Start Free Trial