Need a function to return the number of CPUs

RESOLVED FIXED in 4.1

Status

enhancement
P3
normal
RESOLVED FIXED
20 years ago
19 years ago

People

(Reporter: wtc, Assigned: larryh)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Reporter

Description

20 years ago
We should add a function that returns the
number of CPUs in the system.

Right now, one can obtain this information by
calling the private function PR_GetThreadAffinityMask()
and then counting the number of 1's in the returned
mask.  However, this is a private function and
moreover this function is not implemented in the
pthreads version.

We can either add a new function or add a new
command option to PR_GetSystemInfo().
Reporter

Updated

20 years ago
Severity: normal → enhancement
Status: NEW → ASSIGNED

Comment 1

20 years ago
Adding an option to PR_GetSystemInfo should be fine.

The precise meaning of "number of cpus" should be made clear. For example, the 
number of processors available to run user applications may be different from 
the number of physical processors online.
Reporter

Comment 2

20 years ago
Reassigned to larryh as a NSPR 4.1 feature.
Status: ASSIGNED → NEW
QA Contact: srinivas → wtc
Target Milestone: --- → 4.1
Reporter

Comment 3

20 years ago
Forgot to click on "reassign".
Assignee: wtc → larryh
Assignee

Updated

19 years ago
Status: NEW → ASSIGNED
Assignee

Comment 4

19 years ago
Checking in parts:

Checking in pr/include/prsystem.h;
/cvsroot/mozilla/nsprpub/pr/include/prsystem.h,v  <--  prsystem.h
new revision: 3.5; previous revision: 3.4
done
Checking in pr/src/misc/prsystem.c;
/cvsroot/mozilla/nsprpub/pr/src/misc/prsystem.c,v  <--  prsystem.c
new revision: 3.7; previous revision: 3.6
done
Checking in pr/tests/system.c;
/cvsroot/mozilla/nsprpub/pr/tests/system.c,v  <--  system.c
new revision: 3.3; previous revision: 3.2
done

Assignee

Comment 5

19 years ago
Fix my OS/2 implementation using fix inspired by Skip Nizinski 
<snizinski@us.ibm.com>. Thanks for the help, Skip

Checking in prsystem.c;
/cvsroot/mozilla/nsprpub/pr/src/misc/prsystem.c,v  <--  prsystem.c
new revision: 3.8; previous revision: 3.7
Reporter

Comment 6

19 years ago
I changed _SC_NPROC_CONF to _SC_NPROC_ONLN (we want the number
of online processors).  Made the code compile on HP-UX 10 and
SINIX.
/cvsroot/mozilla/nsprpub/pr/src/misc/prsystem.c, revision 3.9

I found that sysconf(_SC_NPROC_ONLN) (and _SC_NPROC_CONF too)
fails with EINVAL on SINIX-Z 5.42 and SINIX-N 5.43.  I don't
know why.  So I backed out the SINIX (aka RELIANTUNIX) stuff.
/cvsroot/mozilla/nsprpub/pr/src/misc/prsystem.c, revision 3.10
Ops, my linux compile died because a missing #endif in #ifndef ... (version
3.8):

#if defined(OS2)
#define INCL_DOS
#include <os2.h>
/* define the required constant if it is not already defined in the headers */
#ifndef QSV_NUMPROCESSORS
#define QSV_NUMPROCESSORS 26
#endif
ADD AN #endif HERE OR WE'RE IN TROUBLE ... 
Assignee

Comment 8

19 years ago
added missing #endif
Assignee

Comment 9

19 years ago
marking as fixed.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Reporter

Comment 10

19 years ago
Hans Lambermont <hans@blender.nl> pointed out that
BSD-derived systems (BSD/OS, FreeBSD, NetBSD, OpenBSD,
and MacOS X) use sysctl() to get the number of processors.
/cvsroot/mozilla/nsprpub/pr/src/misc/prsystem.c, revision 3.14
Assignee

Comment 11

19 years ago
Hard code the returned value to 1 for MacOS.
You need to log in before you can comment on or make changes to this bug.