Board logo

Subject: CPU affinity [Print This Page]

Author: mikemb78    Time: 2016-12-7 17:37     Subject: CPU affinity


I use the environment "Start IDE with single CPU". This option allows a stable debugging of my project.
But when the option is not set, the behaviour is in my opinion not correct. If the option is not checked the function "TCnWizOptions.SetUseOneCPUCore", sets the process-affinity to the system-affinity and not to the
process-affinity determined with the function "GetProcessAffinityMask". So if I set the affinity external (e.g. with cmd start /affinity 4 bds.exe) this function resets the external preset.

In my opinion this code-snippet gets the expected behaviour:

procedure TCnWizOptions.SetUseOneCPUCore(const Value: Boolean);
  AMask, SysMask: TCnNativeUInt;
  FUseOneCPUCore := Value;
  if GetProcessAffinityMask(GetCurrentProcess, AMask, SysMask) then
    if FUseOneCPUCore then
      SetProcessAffinityMask(GetCurrentProcess, $0001)
      SetProcessAffinityMask(GetCurrentProcess, AMask);

Author: Passion    Time: 2016-12-8 15:38

Seems our typo for this API. We'll correct according to your modification. Thanks!

Welcome to CnPack Forum ( Powered by Discuz! 5.0.0