What *is* the API for sched_getaffinity? Should sched_getaffinity always succeed when using cpu_set_t?
KOSAKI Motohiro
kosaki.motohiro@gmail.com
Tue Jul 16 23:52:00 GMT 2013
(7/16/13 11:35 AM), KOSAKI Motohiro wrote:
> On Tue, Jul 16, 2013 at 7:04 AM, <chrubis@suse.cz> wrote:
>> Hi!
>>> /sys/devices/system/cpu/possible returns possible cpu mask. AFAIK, unfortunately,
>>> sysconf() doesn't support to get possible cpus.
>>
>> There is _SC_NPROCESSORS_CONF and get_nprocs_conf() that counts number
>> of directories with cpu prefix in '/sys/devices/system/'.
>
> They are not exactly match, AFAIK. /sys/devices/system can be changed
> dynamically if the hardware
> have a real hotplug support. But /sys/devices/system/cpu/possible
> never be changed.
>
> /sys/devices/system mean current _recognized_ cpus by kernel. (both
> online and offline). It mean
> logical cpu offlining (uses echo 0 >
> /sys/devices/system/cpu/cpuX/online) doesn't change the directory.
> But physical hotplug (only equipped by IBM, HP and Fujitsu high end
> machine) may change.
off topic:
_SC_NPROCESSORS_CONF and _SC_NPROCESSORS_ONLN are described as followings.
http://www.gnu.org/software/libc/manual/html_node/Processor-Resources.html
>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?
More information about the Libc-alpha
mailing list