with MBS
[quote]SystemInformationMBS.ProcessorCount(Mode as Integer = 0) as integer
method, System, MBS Util Plugin (SystemInformation), module SystemInformationMBS,
Plugin version: 8.2, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.
Function: Returns the number of processors on the target system.
Example:
MsgBox str(SystemInformationMBS.ProcessorCount(1))+" "+str(SystemInformationMBS.ProcessorCount(2))
Notes:
With plugin version 13.3, we added mode parameter. Pass 1 for physical CPU and 2 for logical CPU count on Mac/Win.
On Windows or Mac OS the number of cores.
On Linux the number of configured CPUs.
Returns 1 on any error.[/quote]
without MBS
Mac:
markus$ sysctl -n hw.physicalcpu
2
markus$ sysctl -n hw.ncpu
4
-n Use this option to disable printing of the key name when printing values.
Linux:
In Linux, the sysctl interface mechanism is also exported as part of procfs under the /proc/sys directory (not to be confused with the /sys directory). This difference means checking the value of some parameter requires opening a file in a virtual file system, reading its contents, parsing them and closing the file. The sysctl system call does exist on Linux, but does not have a wrapping function in glibc and is not recommended for use.
The most simplest tool comes with glibc and is called getconf:
$ getconf _NPROCESSORS_ONLN
4
grep -c processor /proc/cpuinfo
Win
You can call the GetSystemInfo function and use the dwNumberOfProcessors member of the SYSTEM_INFO structure.
Have a look at the following example code:
Declare Sub GetSystemInfo Lib “kernel32” Alias “GetSystemInfo” (lpSystemInfo As Ptr)
Dim SystemInfo as MemoryBlock=new MemoryBlock(36)
GetSystemInfo(SystemInfo)
Dim ProcessorCount as Integer=SystemInfo.Long(20)
The SYSTEM_INFO structure has a size of 36 Bytes. The members before dwNumberOfProcessors have a size of 20 bytes.