This is the mail archive of the 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 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

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 {
   int  detachstate;

+#if defined(__rtems__)
+  size_t affinitysetsize;
+  cpu_set_t *affinityset;
+  cpu_set_t affinitysetdefault;
 } 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  :
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

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