Patch - Add pthread affinity for RTEMS

Sebastian Huber sebastian.huber@embedded-brains.de
Mon Nov 25 07:45:00 GMT 2013


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.



More information about the Newlib mailing list