Windows: Disabling C-State Inaction CPU from Kernel-Mode Driver

I am writing an audio device driver that should handle device interrupts in real time. When the CPU enters state C3, interrupts are delayed, causing problems with the driver. Is there a way in which a driver can tell the operating system not to enter idle C states?

I found that unoccupied C-states can be disconnected from user space:

const DWORD DISABLED = 1; const DWORD ENABLED = 0; GUID *scheme; PowerGetActiveScheme(NULL, &scheme); PowerWriteACValueIndex(NULL, scheme, &GUID_PROCESSOR_SETTINGS_SUBGROUP, &GUID_PROCESSOR_IDLE_DISABLE, DISABLED); PowerSetActiveScheme(NULL, scheme); 

However, this is a global parameter that can be overwritten by the user or another application (for example, when the user changes the Power Plan).

I need something like PoRegisterSystemState, but not for S and P states, but for C states. (ref: https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/preventing-system-power-state-changes )

Is there any way to achieve this?

=====

It turns out there is no supported way to disable unoccupied C-states from kernel space, and there is no service in user space to provide a common API for this. The way to manage C-states is to "Processor power control" in the "Change advanced power settings" dialog box, through the registry or through the C API PowerWriteACValueIndex / PowerWriteDCValueIndex.

The initial problem was delaying interrupts in all states except C1, so I needed to disable both C2, C3, and deeper idle states. The problem with disabling all unoccupied C-states, including C1 (as shown in the PowerWriteACValueIndex code example (NULL, schema and GUID_PROCESSOR_SETTINGS_SUBGROUP, and GUID_PROCESSOR_IDLE_DISABLE, DISABLED)), is that CPU usage is reported as 100%, and some applications ( .

The solution to my problem is to disable all the unoccupied state of C1, which can be done by setting the following values ​​in Power Power Management: - Scaling the threshold of the processor β†’ Disable scaling; - A simple processor protection level β†’ 100%; - Threshold of lowering the threshold of the processor β†’ 100%.

Perhaps I will create a service that does just that and uses the PowerWriteACValueIndex / PowerWriteDCValueIndex API.

+7
c windows cpu-speed device-driver
source share

No one has answered this question yet.

See related questions:

719
How to get application exit code from windows command line?
505
How to determine CPU and memory consumption from inside the process?
14
Looking for the cause of an unexpected exception in the Linux kernel module
4
Executing a user space function from kernel space
one
it's a core freeze
one
[Windows Driver Development] How to disable F8 during the Windows boot process?
0
Instant Keyboard Status on Linux
0
Interrupt handler code executed simultaneously with user code
0
Linux SPI process crashes in kernel driver
0
Decrease processor frequency

All Articles