Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 7640ee27c964455ef3fd8349af09d3da82d12afd
Ticket: 3065485fffffffffffffffffffffffffffffffff
TIP 377 : Portably determine number of processors
User & Date: egavilan on 2010-09-24 22:58:51
Changes

  1. icomment:
    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
    
    
    
  2. login: "egavilan"
  3. mimetype: "text/plain"
  4. username: "egavilan"