Recent

Author Topic: [Solved] Number of processors \ cores under Linux  (Read 1217 times)

devEric69

  • Hero Member
  • *****
  • Posts: 648
[Solved] Number of processors \ cores under Linux
« on: February 11, 2020, 11:39:27 am »
Hello,

I would like to get the number of processors of a PC running Linux, to limit the maximum number of workers created at the same time, to this number.
Under Windows, there is GetSystemInfo. Do you know the equivalent under Linux?

Regards.
« Last Edit: February 11, 2020, 11:52:36 am by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Number of processors \ cores under Linux
« Reply #1 on: February 11, 2020, 11:41:23 am »
Code: Pascal  [Select][+][-]
  1. cThreadCount := {$IFDEF UNIX}GetSystemThreadCount{$ELSE}GetCPUCount{$ENDIF};
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: Number of processors \ cores under Linux
« Reply #2 on: February 11, 2020, 11:51:57 am »
It works. Thank you.
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Number of processors \ cores under Linux
« Reply #3 on: February 11, 2020, 11:54:54 am »
Code: Pascal  [Select][+][-]
  1. cThreadCount := {$IFDEF UNIX}GetSystemThreadCount{$ELSE}GetCPUCount{$ENDIF};

uses .... utf8process;

!!!

 

TinyPortal © 2005-2018