|
2026-11-13
| ||
| 11:18 | • Closed ticket [3065485fff]: TIP 377 : Portably determine number of processors</i... artifact: eb059936de user: serhiy.storchaka | |
|
2010-09-24
| ||
| 22:58 | • Ticket [3065485fff]: 4 changes artifact: 7640ee27c9 user: egavilan | |
|
2010-09-17
| ||
| 02:57 | • Add attachment numcpu.c to ticket [3065485fff] artifact: c0e634457e user: andreas_kupries | |
| 02:57 | • Ticket [3065485fff] TIP 377 : Portably determine number of processors status... artifact: 3cc3713d21 user: andreas_kupries | |
|
2010-09-16
| ||
| 22:40 | • Ticket [3065485fff]: 6 changes artifact: 872cfdace4 user: andreas_kupries | |
|
2010-09-15
| ||
| 05:23 | • Ticket [3065485fff]: 4 changes artifact: fe667177d5 user: andreas_kupries | |
| 05:23 | • Add attachment numcpu.c to ticket [3065485fff] artifact: fe5f41aede user: andreas_kupries | |
|
2010-09-13
| ||
| 19:15 | • New ticket [3065485fff] Portable C-API and Tcl cmd to determine number of proces... artifact: 251a71135d user: andreas_kupries | |
TIP 377 : Portably determine number of processors
Closed / Rejected3065485fffffffffffffffffffffffffffffffffCreated 16 years agoUpdated 20 days ago
Descriptionplain2010-09-13 19:15:29
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.
andreas_kupriesplain2010-09-15 05:23:19
File Added - 386677: numcpu.c
andreas_kupriesplain2010-09-16 22:40:24
Now a proper TIP.
andreas_kupriesplain2010-09-17 02:57:54
File Added - 386869: numcpu.c
egavilanplain2010-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.storchakawiki2026-11-13 11:18:44
TIP 377 was withdrawn and no processor count API was added to Tcl, so closing.
Log in (anonymous is fine) to add a comment.
Attachments:
- numcpu.c [download] added by andreas_kupries on 2010-09-17 02:57:54. [details]