Skip to content

Commit

Permalink
Screen/Windows: Allow disable of processor idling disable.
Browse files Browse the repository at this point in the history
We want a way out of the new C-state switching prevention code on Windows.
Now check for existence environment variable PSYCH_DONT_DISABLE_CPU_IDLING
and don't disable processor idling / C-state switching if the variable is set.

The new PsychTweak('DontDisableProcessorIdling', dontDisable) setting
allows to control this from user scripts.

Note this commit also changes end of line markers from DOS CR+LF to Unix
LF, hence the potential impression of large scale changes in this file
with some commit diff tools.
  • Loading branch information
kleinerm committed Oct 7, 2023
1 parent 47c9738 commit 41a2f41
Show file tree
Hide file tree
Showing 2 changed files with 497 additions and 457 deletions.
5 changes: 5 additions & 0 deletions PsychSourceGL/Source/Windows/Screen/PsychWindowGlue.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ psych_bool PsychOSDisableProcessorIdling(psych_bool dontIdle)
{
GUID* activeScheme;

// No-Op with success return if env variable PSYCH_DONT_DISABLE_CPU_IDLING is defined,
// for testing or for interop with cpu tweaking tools - settable via PsychTweak():
if (getenv("PSYCH_DONT_DISABLE_CPU_IDLING"))
return(TRUE);

if (PowerGetActiveScheme(NULL, &activeScheme) ||
PowerWriteACValueIndex(NULL, activeScheme, &GUID_PROCESSOR_SETTINGS_SUBGROUP, &GUID_PROCESSOR_IDLE_DISABLE, dontIdle ? 1 : 0) ||
PowerWriteDCValueIndex(NULL, activeScheme, &GUID_PROCESSOR_SETTINGS_SUBGROUP, &GUID_PROCESSOR_IDLE_DISABLE, dontIdle ? 1 : 0) ||
Expand Down
Loading

0 comments on commit 41a2f41

Please sign in to comment.