Re: API for detection of multiple CPUs

From: David (thunderbolt01_at_netscape.net)
Date: 10/28/03


Date: Tue, 28 Oct 2003 14:31:39 GMT

apm wrote:
> Does anyone know if there is an API for detecting how many CPUs are
> present? I am after a way of programmatically determining whether or
> not a spinlock could be used in preference to a pthread mutex.

Possibly something like this?

if [ -x /usr/bin/getconf ]; then
   CPUS=`getconf _NPROCESSORS_ONLN`
fi
if test "x$CPUS" = "x" -o "x$CPUS" = "x0"; then
   CPUS=1
fi

-- 
Confucius:  He who play in root, eventually kill tree.
Registered with The Linux Counter.  http://counter.li.org/
Slackware 9.1.0 Kernel 2.4.22 SMP i686 (GCC) 3.3.2
Uptime: 21 days, 20:23, 2 users, load average: 0.15, 0.09, 0.0


Relevant Pages

  • Re: API for detection of multiple CPUs
    ... > apm wrote: ... >> Does anyone know if there is an API for detecting how many CPUs are ...
    (comp.os.linux)
  • Re: API for detection of multiple CPUs
    ... > Does anyone know if there is an API for detecting how many CPUs are ... I am after a way of programmatically determining whether or ...
    (comp.os.linux)
  • API for detection of multiple CPUs
    ... Does anyone know if there is an API for detecting how many CPUs are ... I am after a way of programmatically determining whether or ...
    (comp.os.linux)
  • Re: cpuset and affinity implementation
    ... I have implemented a new api similar to processors sets on solaris. ... allows you to assign processes to sets of cpus and dynamically change ... integrated with jail so you can restrict the cpus any jail is allowed to ... Root set - immutable, all cpus, may be root of jail in which case root ...
    (freebsd-current)
  • Re: cpuset and affinity implementation
    ... I have implemented a new api similar to processors sets on solaris. ... allows you to assign processes to sets of cpus and dynamically change those ... integrated with jail so you can restrict the cpus any jail is allowed to ... a big ULE patch I've been working on. ...
    (freebsd-current)