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: [PATCH v3.2] New functions pthread_[sg]etattr_default_np for default thread attributes


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.


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