Re: API for detection of multiple CPUs
From: apm (apm35_at_student.open.ac.uk)
Date: 10/30/03
- Next message: Maurits van de Kamp: "Re: linux box as "router""
- Previous message: Rick: "Re: Open source mail server on windows, oh my..."
- In reply to: David: "Re: API for detection of multiple CPUs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Oct 2003 23:20:32 -0800
David <thunderbolt01@netscape.net> wrote in message news:<f5vnb.50391$e01.126978@attbi_s02>...
> 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
That does the trick on Linux, thanks. Now if only I could find a more
portable way. I need something that will work on Solaris, AIX and HPUX
as well.
-Andrew M.
- Next message: Maurits van de Kamp: "Re: linux box as "router""
- Previous message: Rick: "Re: Open source mail server on windows, oh my..."
- In reply to: David: "Re: API for detection of multiple CPUs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|