Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » OS Problems etc., Win32, POSIX, MacOS, FreeBSD, X11 etc » BSDs: Is there "int get_nprocs (void)"
BSDs: Is there "int get_nprocs (void)" [message #10845] Wed, 01 August 2007 15:46 Go to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
Can anybody check whether the above function is available in BSDs?

Should be in sys/sysinfo.h

Mirek
Re: BSDs: Is there "int get_nprocs (void)" [message #10861 is a reply to message #10845] Wed, 01 August 2007 19:43 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
It is not available in FreeBSD Sad .
Since version 6 there is a function

int pmc_ncpu(void);


as part of the Performance Monitoring Counters API.

One also needs to include pmc.h and link with -lpmc.

Matthias
Re: BSDs: Is there "int get_nprocs (void)" [message #10862 is a reply to message #10845] Wed, 01 August 2007 19:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
What about sysconf(_SC_NPROCESSORS_ONLN) ?

Mirek
Re: BSDs: Is there "int get_nprocs (void)" [message #10865 is a reply to message #10862] Wed, 01 August 2007 19:55 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
Should work, too (and also better solution) Smile.

Matthias

[Updated on: Thu, 02 August 2007 11:04]

Report message to a moderator

Re: BSDs: Is there "int get_nprocs (void)" [message #10878 is a reply to message #10865] Thu, 02 August 2007 11:02 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
On Net-, Open-, DragonflyBSD one must use sysctl system call like that:

int mib[2], maxproc;
size_t len;

mib[0] = CTL_HW;
mib[1] = HW_NCPU;
len = sizeof(maxproc);
sysctl(mib, 2, &maxproc, &len, NULL, 0);


But then the kernel sources have to be installed and the following files have to be included:
<sys/systctl.h> and <sys/param.h> on Net-, OpenBSD and <sys/types.h> on DragonflyBSD.

Matthias

[Updated on: Thu, 02 August 2007 11:27]

Report message to a moderator

Re: BSDs: Is there "int get_nprocs (void)" [message #10884 is a reply to message #10878] Thu, 02 August 2007 14:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
I think on these BSDs, returning 1 is perhaps ok for now...
Re: BSDs: Is there "int get_nprocs (void)" [message #10887 is a reply to message #10884] Thu, 02 August 2007 14:51 Go to previous message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
You are right, especially since there are no official ports available on these systems, yet Rolling Eyes .

Matthias
Previous Topic: Package Problem with Ubuntu 7.04
Next Topic: Win_CE
Goto Forum:
  


Current Time: Wed Nov 20 05:28:15 CET 2019

Total time taken to generate the page: 0.01016 seconds