[fpc-devel] Feature announcement: Extension of TThread's interface
Henry Vermaak
henry.vermaak at gmail.com
Sat Dec 29 15:59:38 CET 2012
On Thu, Dec 27, 2012 at 05:23:17PM +0100, Sven Barth wrote:
> - ProcessorCount (class):
> Returns the count of CPU cores detected by the RTL. This is
> based on the new global property System.GetCPUCount which needs to
> be implemented per target. Currently only a default implementation
> exists which returns "1".
On linux, this can be done with sched_getaffinity, which gives you the
number of processing units that the current process can run on. I guess
this is the number we're looking for here?
If you need all the processors, you need to read the information under
/sys/devices/system/cpu (the topology subdirectory may be handy to
filter out HTT), possibly falling back to /proc/stat and /proc/cpuinfo
if necessary.
Take a look at the `nproc` utility from gnu coreutils.
http://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/nproc.c
http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/getsysstats.c;h=22285f39f33bf26cd55f424ddf4f24300d0d9e72;hb=HEAD
Henry
More information about the fpc-devel
mailing list