Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.

Trying to disable Processor idle states (C states) on Windows PC

mashdev
Beginner
3,258 Views

I need to prevent the processor from entering an idle state (non C0 C state). Admittedly I do not know much about processor C and P states so bear with me. We use a camera from a third party vendor which occasionally delivers corrupted frames. The vendor has determined that when the CPU enters an idle state it interferes with the transmission of the frame over the firewire. To confirm this I used the following code on a Windows 7 PC and indeed, disabling the idle states resolved the issue.

//WIN7
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);

...

If I run my application and open Windows permon and add the %C1 Time, %C2 Time and %C3 time I see that they are all zero when I disable these states, when I enable them I see quite a bit of time spent in the C3 state (this is on a Dell Precision T3500 quad core PC).

I also need to do this on XP however these calls are not available on XP. So I attempted to do the following to disable the idle states

unsigned int ActPwrSch;
DWORD currPolicy,newPolicy, curr1Policy,curr2Policy, new1Policy, new2Policy;
MACHINE_PROCESSOR_POWER_POLICY Policy;
if(GetActivePwrScheme(&ActPwrSch))
{
if(ReadProcessorPwrScheme(ActPwrSch,&Policy))
{
Policy.ProcessorPolicyAc.Policy[0].AllowPromotion = 0;
Policy.ProcessorPolicyAc.Policy[1].AllowPromotion = 0;
Policy.ProcessorPolicyAc.Policy[2].AllowPromotion = 0;
if(WriteProcessorPwrScheme(ActPwrSch,&Policy))
{
printf("WriteProcessorPwrScheme succeed\\n");
if(SetActivePwrScheme(ActPwrSch,0,0))
{
printf("SetActivePwrScheme succeed!!\\n");
}
}

}

...

However when I run my application I still see that the processor is spending time in the C1 state (by looking at the same counters in perfmon). And I still get my corrupted image problem. The XP PC is an single core Dell optiplex PC.

Does anybody know how I can prevent entry into any of the C1-C3 states on XP? As I said it seems that I have done it on Windows 7.

0 Kudos
7 Replies
TimP
Honored Contributor III
3,258 Views
XP went off support before the current hardware became available, so I think your expectations for XP must be limited.
0 Kudos
Patrick_F_Intel1
Employee
3,258 Views
Hello Mashdev,
Have you tried setting the control panel power settings to max performance?
I would also look in the BIOS for any settings such as disabling Cstates.
This would be a good place to start.
Pat
0 Kudos
mashdev
Beginner
3,258 Views
Thanks. There were no settings for C states in the BIOS. I did set to max performance but I still see the processor enter the C1 state when observing in Windows perfmon
0 Kudos
Patrick_F_Intel1
Employee
3,258 Views
On linux you can tell the idle loop to just 'poll' so that it never goes into sleep states.
In case anyone cares, you can do this with a boot option 'idle=poll'.
I don't know of an equivalent function on Windows.

This is sort of a hack but one possibility on windows is to write a program that starts one thread per cpu and does nothing but add to an integer in a permanent loop. Then start this program with the lowest priority.
This will just soak up any idle cycles and prevent the system from going into power saving states.

Pat
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
Quoting mashdev

...We use a camera from a third party vendor which occasionally delivers corrupted frames. The vendor
has determined that when the CPU enters an idle state it interferes with the transmission of the frame
over the firewire...


Ifthe camerauses its own drivera problem could be related to some issues in it. I think your vendor should
find out what is exactly wrong with the driver and to fix it. Shouldn't the driver stop the transmittion of framesas
soon as theCPU enters some idle state?

0 Kudos
mashdev
Beginner
3,258 Views
Sergey,
Yes you are right. Ultimately the vendor should be fixing this. We are looking for a workaround to improve our situation until the issue is resolved or we change cameras or vendors.
0 Kudos
Bernard
Valued Contributor I
3,258 Views
Processor power states coul be also manipulated with the help of kernel debugger(Windbg).You can see current policy by issueing this command !popolicy. IIRC _KPCR structure holds the member structure which is responsible for CPU power management.
0 Kudos
Reply