Q:

Pin processor CPU Isolation on Windows

In linux where I work mostly, we use a technique called CPU isolation, that effectively locks a process on to a processor and also prevents the processor from running anything else.  Our kernel guys did some magic to handle the interrupts.
In windows the closest thing I found is an affinity concept which appears to bind a process/thread to a processor.  But it makes no guarantee that the processor is ONLY running that process/thread meaning there can still be context switch and other jitter.
Is there a way to have a CPU isolated on windows for semi-deterministic running times?

A:

There's no exact way to to this in user mode. And Windows mostly tries to prevent apps from hogging up all the system resources. But you could probably isolate the majority of other processes to another core/processor such that your code can run on a core mostly dedicated to it.
Start by looking at this code here on MSDN on enumerating processes. Except your enumeration code will specify PROCESS_SET_INFORMATION as the flag to OpenProcess.   You'll likely need your code running with admin privs to do this for processes not running as your NT creds. For each process handle obtained, call SetProcessAffinityMask to set the process to run on all cores but one. Then set your your process to run another on the reserved core you culled out from all the other process handles.
This won't handle other processes from starting up and getting load balanced to the core you are trying to run your code on.
Your mileage may vary. If this is just for testing or for machines dedicated to your code, then it will probably be fine. If this is for a commercial app meant to run alongside all other apps, customers will be terribly disappointed to see all their other apps and services tank when they run your code.  Tread carefully.

