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