Board logo

Subject: CPU affinity [Print This Page]

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

Hi,

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);
var
  AMask, SysMask: TCnNativeUInt;
begin
  FUseOneCPUCore := Value;
  if GetProcessAffinityMask(GetCurrentProcess, AMask, SysMask) then
  begin
    if FUseOneCPUCore then
      SetProcessAffinityMask(GetCurrentProcess, $0001)
    else
      SetProcessAffinityMask(GetCurrentProcess, AMask);
  end;
end;

Regards
Mike
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 (http://bbs.cnpack.org/) Powered by Discuz! 5.0.0