This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v3.2] New functions pthread_[sg]etattr_default_np for default thread attributes
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: Roland McGrath <roland at hack dot frob dot com>, libc-alpha at sourceware dot org
- Date: Thu, 13 Jun 2013 12:05:02 -0400
- Subject: Re: [PATCH v3.2] New functions pthread_[sg]etattr_default_np for default thread attributes
- References: <20130315043154 dot GG22471 at spoyarek dot pnq dot redhat dot com> <20130318222239 dot 7A2712C084 at topped-with-meat dot com> <CAAHN_R13bRF0UY_XZ7Rj6tSeSgq8c_0j4bbEH6m9BbGD32EycQ at mail dot gmail dot com> <20130528220730 dot 33C262C06F at topped-with-meat dot com> <20130529065138 dot GF2145 at spoyarek dot pnq dot redhat dot com> <20130529224222 dot 8A87F2C07E at topped-with-meat dot com> <20130606131212 dot GZ13968 at spoyarek dot pnq dot redhat dot com> <20130612000601 dot 54C9F2C06E at topped-with-meat dot com> <20130612101128 dot GB19582 at spoyarek dot pnq dot redhat dot com> <20130612231757 dot CCC752C07F at topped-with-meat dot com> <20130613035538 dot GL19582 at spoyarek dot pnq dot redhat dot com>
On 06/12/2013 11:55 PM, Siddhesh Poyarekar wrote:
> +verify_affinity_result (pthread_attr_t *attr)
> +{
> + cpu_set_t cpuset;
> +
> + RETURN_IF_FAIL (pthread_attr_getaffinity_np, attr, sizeof (cpuset), &cpuset);
This will fail if booted on a system with more than 1024 possible CPUs.
You need to use sysconf(_SC_PROCESSORS_ONLN); to get the size of the
required set, allocate it, and then use that size in the call.
> + if (!CPU_ISSET (0, &cpuset))
> + {
> + puts ("failed to set cpu affinity");
> + return 1;
> + }
> +
> + return 0;
> +}
Cheers,
Carlos.