| Ticket UUID: | 3065485 | ||
| Title: | TIP 377 : Portably determine number of processors | ||
| Type: | RFE | Created on: | 2010-09-13 19:15:29 |
| Submitter: | andreas_kupries | Assigned to: | vasiljevic |
| Subsystem: | 54. Configuration Reporting | Severity: | |
| Priority: | 5 Medium | Last modified: | 2026-11-13 11:18:44 |
| Status: | Closed | Closed by: | serhiy.storchaka |
| Resolution: | Rejected | Closed on: | 2026-11-13 11:18:43 |
| Version: | None | ||
| Description: | ||||
For initialization of thread pools to a sensible size it would be useful to know the number of processors/cores/... the current machine has. The following link has quite a bit of info for various platforms: http://stackoverflow.com/questions/150355/programmatically-find-the-number-of-cores-on-a-machine The C-level API might be best to have in Tcl itself, the Tcl command however should be in the Thread package, IMHO. | ||||
| User Comments: | ||||
andreas_kupries added on 2010-09-15 05:23:19:
File Added - 386677: numcpu.c andreas_kupries added on 2010-09-16 22:40:24:
Now a proper TIP. andreas_kupries added on 2010-09-17 02:57:54:
File Added - 386869: numcpu.c egavilan added on 2010-09-24 22:58:51:
On modern BSDs, you can get the number of CPUs used by the kernel with
int numCPU;
int mib[2];
size_t len;
/* set the mib for hw.ncpu */
mib[0] = CTL_HW;
mib[1] = HW_NCPU;
/* get the number of CPUs from the system */
sysctl(mib, 2, &numCPU, &len, NULL, 0);
the #includes needed are
#include <sys/types.h>
#include <sys/sysctl.h>
for {Free|Dragonfly}BSD and
#include <sys/param.h>
#include <sys/sysctl.h>
For {Open|Net}BSD
serhiy.storchaka added on 2026-11-13 11:18:44:
TIP 377 was withdrawn and no processor count API was added to Tcl, so closing. | ||||
