This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: Patch - Add pthread affinity for RTEMS
- From: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- To: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- Cc: "newlib at sourceware dot org" <newlib at sourceware dot org>, Chris Johns <chrisj at rtems dot org>, Gedare Bloom <gedare at rtems dot org>
- Date: Fri, 22 Nov 2013 13:20:04 -0600
- Subject: Re: Patch - Add pthread affinity for RTEMS
- Authentication-results: sourceware.org; auth=none
- References: <528F6A68 dot 1070607 at oarcorp dot com> <528F6F2B dot 3060600 at embedded-brains dot de>
On 11/22/2013 8:50 AM, Sebastian Huber wrote:
> On 2013-11-22 15:30, Joel Sherrill wrote:
>> Hi
>>
>> This patch follows up on the recent addition of the
>> RTEMS specific cpuset.h and adds GNU/Linux style
>> pthread affinity APIs to pthread.h.
>>
>> Sebastian.. we think the guards follow your recommendations.
Jennifer thinks I grabbed the version before your recommendation.
More below.
>>
>> OK to commit?
>>
>> 2013-11-22 Jennifer Averett<jennifer.averett@oarcorp.com>
>>
>> * libc/include/pthread.h (pthread_attr_setaffinity_np,
>> pthread_attr_getaffinity_np, pthread_setaffinity_np,
>> pthread_getaffinity_np, pthread_getattr_np): Add pthread obtain
>> attribute and SMP affinity methods to RTEMS for compatibility
>> with GNU/Linux.
>> * libc/include/sys/types.h: Add cpuset to pthread_attr_t for RTEMS.
>>
>> -- Joel Sherrill, Ph.D. Director of Research & Development
>> joel.sherrill@OARcorp.com On-Line Applications Research Ask me about RTEMS: a
>> free RTOS Huntsville AL 35805 Support Available (256) 722-9985
>>
>>
>> pthread-affinity.diff
>>
>>
>> ? newlib/libc/include/sys/.types.h.swp
>> ? newlib/libc/sys/rtems/sys/cpuset.h
>> Index: newlib/libc/include/pthread.h
>> ===================================================================
>> RCS file: /cvs/src/src/newlib/libc/include/pthread.h,v
>> retrieving revision 1.10
>> diff -u -r1.10 pthread.h
>> --- newlib/libc/include/pthread.h 22 Jan 2013 21:20:08 -0000 1.10
>> +++ newlib/libc/include/pthread.h 11 Nov 2013 19:51:02 -0000
>> @@ -2,7 +2,7 @@
>> *
>> * Written by Joel Sherrill<joel@OARcorp.com>.
>> *
>> - * COPYRIGHT (c) 1989-2010.
>> + * COPYRIGHT (c) 1989-2013.
>> * On-Line Applications Research Corporation (OAR).
>> *
>> * Permission to use, copy, modify, and distribute this software for any
>> @@ -206,6 +206,24 @@
>> int _EXFUN(pthread_attr_setguardsize,
>> (pthread_attr_t *__attr, size_t __guardsize));
>>
>> +#if defined(__USE_GNU) && defined(__rtems__)
>
> I would rather use
>
> #ifdef _GNU_SOURCE
This is translated to "__USE_GNU" in <sys/cdefs.h> in the
new version and the guard on specific code blocks is
"__USE_GNU". I think this is what you and Corinna suggested.
>From new cdefs.h
+#ifdef _GNU_SOURCE
+# define __USE_GNU 1
+#endif
>> +#if defined(__rtems__)
>> + size_t guardsize;
>> + cpu_set_t affinity;
>
> In the pthread_attr_setaffinity_np() function we allow arbitrary sized CPU
> sets. What happens if sizeof(cpu_set_t) < __cpusetsize?
We do not have the CPUSET APIs for variable sized cpu_set_t.
For now, if sizeof(cpu_set_t) != __cpusetsize, then it is an
error.
This is an implementation detail until we decide to add the
variable size cpu_set_t APIs to cpuset.h and follow up in
the implementation of affinity routines in RTEMS.
Cynically, we have a lot of work to do before we have to
worry about more than 32 cores. We can fix this along the
way if it is a problem. :)
--
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherrill@OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985