[lsb-discuss] LSB-compliant way to get number of processors?

Nick Stoughton nick at usenix.org
Mon Aug 7 10:05:42 PDT 2006


The sysconf() interface itself is in the LSB.

But only the symbols defined in POSIX are required to be present. We
need to add several, including _SC_NPROCESSORS_ONLN. 

The following _SC_ symbols are defined on my FC5 system that are NOT in
the LSB:
_SC_2_PBS
_SC_AVPHYS_PAGES
_SC_BASE
_SC_CHAR_BIT
_SC_CHARCLASS_NAME_MAX
_SC_CHAR_MAX
_SC_CHAR_MIN
_SC_C_LANG_SUPPORT
_SC_C_LANG_SUPPORT_R
_SC_DEVICE_IO
_SC_DEVICE_SPECIFIC
_SC_DEVICE_SPECIFIC_R
_SC_EQUIV_CLASS_MAX
_SC_FD_MGMT
_SC_FIFO
_SC_FILE_ATTRIBUTES
_SC_FILE_LOCKING
_SC_FILE_SYSTEM
_SC_INT_MAX
_SC_INT_MIN
_SC_IOV_MAX
_SC_IPV6
_SC_LEVEL1_DCACHE_ASSOC
_SC_LEVEL1_DCACHE_LINESIZE
_SC_LEVEL1_DCACHE_SIZE
_SC_LEVEL1_ICACHE_ASSOC
_SC_LEVEL1_ICACHE_LINESIZE
_SC_LEVEL1_ICACHE_SIZE
_SC_LEVEL2_CACHE_ASSOC
_SC_LEVEL2_CACHE_LINESIZE
_SC_LEVEL2_CACHE_SIZE
_SC_LEVEL3_CACHE_ASSOC
_SC_LEVEL3_CACHE_LINESIZE
_SC_LEVEL3_CACHE_SIZE
_SC_LEVEL4_CACHE_ASSOC
_SC_LEVEL4_CACHE_LINESIZE
_SC_LEVEL4_CACHE_SIZE
_SC_LONG_BIT
_SC_MB_LEN_MAX
_SC_MULTI_PROCESS
_SC_NETWORKING
_SC_NL_ARGMAX
_SC_NL_LANGMAX
_SC_NL_MSGMAX
_SC_NL_NMAX
_SC_NL_SETMAX
_SC_NL_TEXTMAX
_SC_NPROCESSORS_CONF
_SC_NPROCESSORS_ONLN
_SC_NZERO
_SC_PHYS_PAGES
_SC_PII
_SC_PII_INTERNET
_SC_PII_INTERNET_DGRAM
_SC_PII_INTERNET_STREAM
_SC_PII_OSI
_SC_PII_OSI_CLTS
_SC_PII_OSI_COTS
_SC_PII_OSI_M
_SC_PII_SOCKET
_SC_PII_XTI
_SC_PIPE
_SC_POLL
_SC_RAW_SOCKETS
_SC_REGEX_VERSION
_SC_SCHAR_MAX
_SC_SCHAR_MIN
_SC_SELECT
_SC_SHRT_MAX
_SC_SHRT_MIN
_SC_SIGNALS
_SC_SINGLE_PROCESS
_SC_SSIZE_MAX
_SC_STREAMS
_SC_SYSTEM_DATABASE
_SC_SYSTEM_DATABASE_R
_SC_T_IOV_MAX
_SC_UCHAR_MAX
_SC_UINT_MAX
_SC_UIO_MAXIOV
_SC_ULONG_MAX
_SC_USER_GROUPS
_SC_USER_GROUPS_R
_SC_USHRT_MAX
_SC_WORD_BIT
_SC_XOPEN_XCU_VERSION
_SC_XOPEN_XPG2
_SC_XOPEN_XPG3
_SC_XOPEN_XPG4


-- quite a list! I see no reason why ALL these symbols shouldn't be
added to the LSB at 3.2, though it is possible/probable that some are
architecture specific.


On Mon, 2006-08-07 at 11:31 +0100, Alan Cox wrote:
> Ar Llu, 2006-08-07 am 10:01 +0100, ysgrifennodd Dallman, John:
> > > I've found two ways so far to ask Linux how many processors 
> > > it has: get_nprocs() and sysconf(_SC_NPROCESSORS_ONLN), but 
> > > neither of them seem to be allowed in LSB-compliant code. 
> > 
> > Any offers? If we can't find a way to do this, Parasolid on 
> > Linux is going to have to cease being LSB-compliant. This is 
> > not a prospect I welcome, but delivering what the customer
> > are actually asking for has to take priority over things 
> > they aren't bothered about. 
> 
> sysconf really ought to be in the LSB for some of those queries. I'd
> agree its a bug if it isnt
> 

-- 
Nick Stoughton                          Cell: 510 388 1413
USENIX Standards Liaison                Fax:  510 548 5738




More information about the lsb-discuss mailing list