This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: What *is* the API for sched_getaffinity? Should sched_getaffinity always succeed when using cpu_set_t?


Hi!
> >The use of threads or processes with shared memory allows an application to take advantage of all
> >the processing power a system can provide. If the task can be parallelized the optimal way to >write an application is to have at any time as many processes running as there are processors.
> >To determine the number of processors available to the system one can run
> >
> >      sysconf (_SC_NPROCESSORS_CONF)
> >
> >which returns the number of processors the operating system configured. But it might be possible >for the operating system to disable individual processors and so the call
> >
> >       sysconf (_SC_NPROCESSORS_ONLN)
> >
> > returns the number of processors which are currently online (i.e., available).
> 
> 
> So, I doubt we should use /sys/devices/system/cpu/possible for _SC_NPROCESSORS_CONF. But "system one can run" seems a bit unclear and I'm not 100% sure we should do. Do anyone know the purpose and intention of _SC_NPROCESSORS_CONF?

It looks like the whole subjects is confusing, and kernel was patched to
make this counting even work see 4d658d13c90f14cf3510ca15cafe2f4aa9e23d64.

But I'm not 100% sure what the change did but it looks to me like this
changed kernel to create cpu sys entires for all sockets on the bus
rather than only for present ones.

It also looks like some time ago both calls were aliases and the only
source of information about available processors was /proc/cpuinfo.
(see git log on glibc sysdeps/unix/sysv/linux/getsysstats.c)

Anyway this interface needs better description in manual pages. I can
prepare a patch once we are sure what information it returns.

-- 
Cyril Hrubis
chrubis@suse.cz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]