Great, got it, thanks: sysconf(_SC_NPROCESSORS_CONF) parses
/proc/cpuinfo
using a simple parser:
#ifndef GET_NPROCS_PARSER
# define GET_NPROCS_PARSER(FP, BUFFER, RESULT)
\
do
\
{
\
(RESULT) = 0;
\
/* Read all lines and count the lines starting with the string
\
"processor". We don't have to fear extremely long lines since
\
the kernel will not generate them. 8192 bytes are really
\
enough. */
\
while (fgets_unlocked (BUFFER, sizeof (BUFFER), FP) != NULL)
\
if (strncmp (BUFFER, "processor", 9) == 0)
\
++(RESULT);
\
}
\
while (0)
#endif
It's being tricked by this:
luyer@praxis8:~$ cat /proc/cpuinfo | grep '^processor'
processor : 0
processor id : 0
processor : 1
processor id : 0
The "processor id" line, only present with SMP enabled, is being counted
as a processor.
David.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/