Mattias Gaertner pisze:
I need a default value of the number of maximum threads.
Is there already some RTL function that can be used for that?
For example if the program runs on a 2 x quad core it would be nice to
get 8.
Hyperthreading multipliers should be applied.
I've found something on:
http://blogs.msdn.com/oldnewthing/archive/2005/12/16/504659.aspx
function AvailableProcessorCount: DWORD;
//returns total number of processors available to system including
logical hyperthreaded processors
var
i: Integer;
ProcessAffinityMask, SystemAffinityMask: DWORD;
Mask: DWORD;
begin
if GetProcessAffinityMask(GetCurrentProcess, ProcessAffinityMask,
SystemAffinityMask) then begin
Result := 0;
for i := 0 to 31 do begin
Mask := 1 shl i;
if (ProcessAffinityMask and Mask)<>0 then begin
inc(Result);
end;
end;
end else begin
//can't get the affinity mask so we just report the total number of
processors
Result := OperatingSystemInfo.ProcessorCount;
end;
end; (* AvailableProcessorCount *)
--
Darek
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal