WindowsInternals icon indicating copy to clipboard operation
WindowsInternals copied to clipboard

How to "escape" the system-wide CPU set?

Open forderud opened this issue 5 years ago • 14 comments

Thanks for a great book Pavel, and for sharing code samples. I'm interested in using CPU Sets to dedicate certain CPU cores to real-time signal processing tasks.

I've played a bit with CpuSet.exe based on the instructions in Windows Internals 7th ed. Part 1, and have successfully managed to change the system-wide CPU set. Changing the CPU set for a given process also works, but only within the system-wide CPU set. This means that I'm not able to reproduce "EXPERIMENT: CPU sets" in the book where CPU 0 is dedicated to the CPUSTRESS process.

Any advise on how to configure a process to "escape" the system-wide CPU set, so that it can get dedicated CPU cores?

Not sure if it's relevant, but I'm running Win10 Pro version 1903 (64bit) build 18362.267.

forderud avatar Aug 12 '19 16:08 forderud

Hi Fredrik, It should work... at least it did back then in the RS1 days. I'll have to test it myself, but essentially CPU sets should allow escaping from the system CPU set just a thread can escape its process CPU set.

zodiacon avatar Aug 12 '19 17:08 zodiacon

@zodiacon Any updates on reproducing this issue?

forderud avatar Aug 25 '19 18:08 forderud

Sorry, I've been super busy with work and other stuff and didn't get around to it yet.

zodiacon avatar Aug 25 '19 18:08 zodiacon

Gentle reminder.

forderud avatar Dec 17 '19 11:12 forderud

Really sorry for the crazy delay... It seems to work ok if you also set affinity for the process, not just the CPU set

zodiacon avatar Jan 13 '21 18:01 zodiacon

It also seems that at some point the system CPU set is reset, need further testing to understand why.

zodiacon avatar Jan 13 '21 18:01 zodiacon

It also seems that at some point the system CPU set is reset, need further testing to understand why.

I've also experienced the same behavior, which really puzzled me.

forderud avatar Jan 13 '21 22:01 forderud

Status update: Microsoft have published How to set up a Device for Real-Time Performance that documents a MDM_WindowsIoT_SoftRealTimeProperties01 management interface for configuring the system-wide CPU set. I guess this is the recommended interface for doing so.

forderud avatar Dec 14 '22 14:12 forderud

Thank you for this.

zodiacon avatar Dec 14 '22 15:12 zodiacon

@forderud Have you successfully run an application on a dedicated CPU? Can the MDM_WindowsIoT_SoftRealTimeProperties01 setting be used on any Windows 10/11 or only on Windows IoT?

ToGoOrNotToGo avatar May 27 '23 07:05 ToGoOrNotToGo

@forderud Have you successfully run an application on a dedicated CPU? Can the MDM_WindowsIoT_SoftRealTimeProperties01 setting be used on any Windows 10/11 or only on Windows IoT?

I just tested on a Windows 11 Pro 21H2, and SoftRT seemed to work fine there.

Just follow the instructions on https://learn.microsoft.com/en-us/windows/iot/iot-enterprise/soft-real-time/soft-real-time-device#use-mdm-bridge-wmi-provider-to-configure-the-windowsiot-csp if you want to test yourself. I recommend testing in a VM, since it's difficult (and possibly impossible) to disable the feature after being enabled.

forderud avatar May 27 '23 15:05 forderud

I'll try it. Thanks! Or do you know that it is not possible to stably handle a callback in which a CRC is calculated every 10 ms? Is this possible with soft real time or only with hard real time? Hard real time should be possible with a dedicated CPU core (CPU set?) right?

ToGoOrNotToGo avatar May 28 '23 09:05 ToGoOrNotToGo

@forderud Have you successfully run an application on a dedicated CPU? Can the MDM_WindowsIoT_SoftRealTimeProperties01 setting be used on any Windows 10/11 or only on Windows IoT?

I just tested on a Windows 11 Pro 21H2, and SoftRT seemed to work fine there.

Just follow the instructions on https://learn.microsoft.com/en-us/windows/iot/iot-enterprise/soft-real-time/soft-real-time-device#use-mdm-bridge-wmi-provider-to-configure-the-windowsiot-csp if you want to test yourself. I recommend testing in a VM, since it's difficult (and possibly impossible) to disable the feature after being enabled.

The feature can be reverted by deleting the ReservedCpuSets registry key. I created a program to extend the functionality of the feature in amitxv/ReservedCpuSets

ghost avatar Jun 27 '23 19:06 ghost

Thanks a lot for informing about the HKLM\System\CurrentControlSet\Control\Session Manager\kernel\ReservedCpuSets registry key @amitxv. This seems like a useful short-term fix for disabling Soft-RT.

I've added a note of the registry key in a Document how to disable Soft-RT enhancement request to Microsoft that I've previously opened.

forderud avatar Jun 28 '23 06:06 forderud