This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: Patch - Add pthread affinity for RTEMS
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- 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: Mon, 25 Nov 2013 08:44:56 +0100
- 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> <528FAE64 dot 8020907 at oarcorp dot com>
On 2013-11-22 20:20, Joel Sherrill wrote:
>>+#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.:)
We should prevent future incompatibilities.
I would use this:
diff --git a/newlib/libc/include/sys/types.h b/newlib/libc/include/sys/types.h
index 0627ca9..58b1520 100644
--- a/newlib/libc/include/sys/types.h
+++ b/newlib/libc/include/sys/types.h
@@ -352,6 +352,11 @@ typedef struct {
#endif
int detachstate;
+#if defined(__rtems__)
+ size_t affinitysetsize;
+ cpu_set_t *affinityset;
+ cpu_set_t affinitysetdefault;
+#endif
} pthread_attr_t;
#endif /* !defined(__XMK__) */
In case the normal cpu_set_t is sufficient, then
pthread_attr_setaffinity_np(attr, cpusetsize, cpuset) can use
attr->affinityset = &attr->affinitysetdefault;
to avoid dynamic memory.
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.