CPU processor isolation in Windows

In linux, where I mainly work, we use a method called CPU isolation, which effectively blocks the process on the processor and also prevents anything else from starting. Our kernel guys did the magic to handle interrupts.

In windows, the closest thing I found is the concept of proximity, which seems to connect the process / thread to the processor. But it does not guarantee that the processor ONLY works, that the process / thread means that there can still be a context switch and another jitter.

Is there a way to isolate the CPU from windows for half-determinate runtime?

+6
source share
1 answer

In user mode, there is no exact way. And Windows is basically trying to prevent applications from overloading all system resources. But you could probably isolate most of the other processes with a different core / processor so that your code can run on the main core of it.

Start by searching in this code here on MSDN for a listing of processes. In addition to the enumeration code, PROCESS_SET_INFORMATION will be indicated as the OpenProcess flag. Most likely, you will need your code running with admin privs to do this for processes that do not work like your NT credits. For each handler being processed, call SetProcessAffinityMask to configure the process on all but one of the cores. Then set your process to run another on the backup kernel that you selected from all the other process descriptors.

This will not handle other processes when starting and balancing the load in the kernel on which you are trying to run your code.

Your mileage may vary. If it's just for testing or for machines dedicated to your code, then this is likely to be good. If this is for a commercial application designed to work with all other applications, customers will be terribly disappointed to see all their other applications and service tanks when they run your code. Protector carefully.

+3
source

All Articles