This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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 - Add pthread affinity for RTEMS


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


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