Re: For review: pthread_setaffinity_np.3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Nov 8, 2008 at 23:31, Loic Domaigne <tech@xxxxxxxxxxxx> wrote:> Hi Michael,>> this one is not 'straightforward' for me as I needed to look into the glibc> and kernel source...>> I am not very knowledgeable in that area, so my review comments are in> consequence...>> Cheers,> Loïc> -->>> .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk>> .\"     <mtk.manpages@xxxxxxxxx>>> .\">> .\" Permission is granted to make and distribute verbatim copies of this>> .\" manual provided the copyright notice and this permission notice are>> .\" preserved on all copies.>> .\">> .\" Permission is granted to copy and distribute modified versions of this>> .\" manual under the conditions for verbatim copying, provided that the>> .\" entire resulting derived work is distributed under the terms of a>> .\" permission notice identical to this one.>> .\">> .\" Since the Linux kernel and libraries are constantly changing, this>> .\" manual page may be incorrect or out-of-date.  The author(s) assume no>> .\" responsibility for errors or omissions, or for damages resulting from>> .\" the use of the information contained herein.  The author(s) may not>> .\" have taken the same level of care in the production of this manual,>> .\" which is licensed free of charge, as they might when working>> .\" professionally.>> .\">> .\" Formatted or processed versions of this manual, if unaccompanied by>> .\" the source, must acknowledge the copyright and authors of this work.>> .\">> .TH PTHREAD_SETAFFINITY_NP 3 2008-11-04 "Linux" "Linux Programmer's>> Manual">> .SH NAME>> pthread_setaffinity_np, pthread_getaffinity_np \- set/get>> CPU affinity of a thread>> .SH SYNOPSIS>> .nf>> .B #define _GNU_SOURCE>> .B #include <pthread.h>>>>> .BI "int pthread_setaffinity_np(pthread_t " thread ", size_t " cpusetsize>> ,>> .BI "                           const cpu_set_t *" cpuset );>> .BI "int pthread_getaffinity_np(pthread_t " thread ", size_t " cpusetsize>> ,>> .BI "                           cpu_set_t *" cpuset );>> .sp>> Compile and link with \fI\-pthread\fP.>> .SH DESCRIPTION>> The>> .BR pthread_setaffinity_np ()>> sets the CPU affinity mask of the thread>> .I thread>> to the CPU set pointed to by>> .IR cpuset .>> If the call is successful,>> and the thread is not currently running on one of the CPUs in>> .IR cpuset ,>> then it is migrated to one of those CPUs.>>>> The>> .BR pthread_getaffinity_np ()>> function returns the CPU affinity mask of the thread>> .I thread>> in the buffer pointed to by>> .IR cpuset .>>>> The argument>> .I cpusetsize>> is the length (in bytes) of the buffer pointed to by>> .IR cpuset .>> Normally this argument would be specified as>> .IR sizeof(cpu_set_t) .>> The constant>> .B CPU_SETSIZE>> specifies a value one greater than the>> maximum CPU number that can be stored in a CPU set.>> I came independently to the same conclusion than you. AFAICS,glibc defines> the cpu_set_t to be a 1024 bits long structure. But the kernel defines the> corresponding structure to be a bit field of appropriate length to store> NR_CPUS.>> Interesting enough, the exact size of the kernel structure is determined by> the glibc on the 1st call to pthread_setaffinity_np().>> We'll run into troubles if run this on a server with more than 1K core ;-)Thats why glibc provides a new set of function to handle cpu_set_twith more than 1K bits.Look for the definitions of macros with a _S suffix in <sched.h>.
Bert��.n��������+%������w��{.n�����{��f��)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux