Preston Smith <[EMAIL PROTECTED]> writes:

> On Thu, Aug 15, 2002 at 03:11:34PM +0200, Leif Nixon ([EMAIL PROTECTED]) 
> wrote:
> > A tentative fix would be to instead count the number of lines
> > starting with "processor" in /proc/cpuinfo.
> 
>  There's been a bug filed about this exact issue on the sourceforge
>  page for some time, but I'd not thought to look at it.
> 
>  This solution will work on x86, but I'll check and see what the most portable
>  way to get it on every linux architecture is. I know counting 'processor'
>  in /proc/cpuinfo won't work on linux sparc, so I'll check other archs
>  as well and get a good fix.

I've done a bit more digging around, and it doesn't seem like much
fun to try to parse /proc/cpuinfo in a portable way.

*However*, it turns out glibc already does this!

sysconf(_SC_NPROCESSORS_CONF) should work on x86, sparc, alpha, mips
and, probably, ia64.

-- 
Leif Nixon                                    Systems expert
------------------------------------------------------------
National Supercomputer Centre           Linkoping University
------------------------------------------------------------

Reply via email to