2016-12-7 17:37 mikemb78
CPU affinity

Hi,

I use the environment "Start IDE with single CPU". This option allows a stable debugging of my project. :handshake
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, [b]AMask[/b]);
  end;
end;

Regards
Mike

2016-12-8 15:38 Passion
Seems our typo for this API. We'll correct according to your modification. Thanks!:handshake

页: [1]
查看完整版本: CPU affinity


Powered by Discuz! Archiver 5.0.0  © 2001-2006 Comsenz Inc.