Question

I will be writing an interface in C++ that controls a large CNC machine and it will run on Windows. For safety reasons, I would like this process to run on it's own core so that it can run the process in real-time. If it shares a core with Windows, all of the Windows processes will be dealt with before my process is. Basically, how do I make sure either my process is always in the front of the processing queue, or how do I designate a core to run my process and leave the other core to handle Windows? Also, is there any way of seeing that my programming is run in real-time. AKA, this core is processing this program, but that core is not doing anything because we told out program not to run on it. Any input would be helpful.

Was it helpful?

Solution

There is no guarantee your process will be dealt with in real time. Windows does not do that. Since you mention safety, I will mention that if a lawsuit occurred you would be in deep trouble. Expert witnesses would testify that the design is inherently unsafe.

User control and display can be done in Windows but real time operations belong in dedicated hardware such as a PLC.

OTHER TIPS

You can use SetThreadAffinityMask to restrict a thread to running on some subset of available processors/cores.

If you use SetThreadPriority and SetProcessPriorityClass to set a thread to real time priority, only other threads running at real time priority can interrupt it, effectively forcing other threads to run on other cores (unless you raise two or more threads to real time priority.

As an alternative, Windows Embedded Compact is a realtime priority-based OS that can make soft realtime guarantees (far better than Windows Vista/7). It's costly, but on par with other commercial RTOSes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top