Hello,

please check https://github.com/genodelabs/genode/issues/3786, which added the 
support to request the number of CPU available to libc recently.

Cheers,

Alex.

On 24.07.20 10:56, Alexander Tormasov via users wrote:
> I am trying to understand how many cpu or/and cored are available for running 
> application.
> 
> I check code related to sysctl in 
> libports/src/lib/libc/sysctl.cc<http://sysctl.cc>
> and found
> extern "C" int __sysctl(const int *name, u_int namelen,
> void *oldp, size_t *oldlenp,
> const void *newp, size_t newlen)
> {
> …
> /* fallback values */
> {
> switch(index_a) {
> 
> …
> case CTL_HW: switch(index_b) {
> 
> case HW_MACHINE:
> *oldlenp = 0;
> return 0;
> 
> case HW_NCPU:
> *(int*)oldp = 1;
> *oldlenp = sizeof(int);
> return 0;
> 
> } break;
> 
> …
> in short, if I used standardised for BSD code (like below in golang) it 
> always return 1!
> 
> int32
> getproccount(void)
> {
> int mib[2], out;
> size_t len;
> 
> mib[0] = CTL_HW;
> mib[1] = HW_NCPU;
> len = sizeof(out);
> if(sysctl(mib, 2, &out, &len, NULL, 0) >= 0)
> return (int32)out;
> else
> return 0;
> }
> 
> Any suggestions? How I can have portable code for Genode to obtain at least 
> NCPU?
> 
> Sincerely,
> Alexander
> 
> 
> _______________________________________________
> Genode users mailing list
> [email protected]
> https://lists.genode.org/listinfo/users
> 

-- 
Alexander Boettcher
Genode Labs

https://www.genode-labs.com - https://www.genode.org

Genode Labs GmbH - Amtsgericht Dresden - HRB 28424 - Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth

_______________________________________________
Genode users mailing list
[email protected]
https://lists.genode.org/listinfo/users

Reply via email to