RFCL cpuset APIs

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Oct 14 07:22:18 UTC 2013

Hello Joel,

I would provide a super set of the FreeBSD and Linux APIs for RTEMS and use a 
clean implementation.  In case of conflicts I would use the Linux API.  Its 
just managing bits.

On 2013-10-11 23:06, Joel Sherrill wrote:
> Hi
> We are finishing up a proposal for pthread affinity APIs. We
> think we should follow the Linux API but have our own
> implementation.  I am trying to use the FreeBSD cpu set code
> with minimal ifdefs, but there are differences which are
> adding up to the point where I have a problem. Do I put in
> lots of ifdef's? Or just create our own version using
> the BSD version as inspiration and code fragements?
> The first difference is Linux uses cpu_set_t while
> FreeBSD uses cpuset_t. This can be accounted for with
> a typedef. A global search and replace or using ifdefs
> will result in a file with lots of changes. Assume a
> typedef is OK since it minimizes impact of that.
> Then you have supporting macros.  The following summarizes
> the similarities and differences.
> These macros appear to be the same on Linux and FreeBSD.
>    void CPU_ZERO(cpu_set_t *set);
>    void CPU_SET(int cpu, cpu_set_t *set);
>    void CPU_CLR(int cpu, cpu_set_t *set);
>    int  CPU_ISSET(int cpu, cpu_set_t *set);
> For comparing sets, Linux has CPU_EQUAL while BSD has CPU_CMP.
> The signature is the same so a renaming macro would address this.
>    int  CPU_EQUAL(cpu_set_t *set1, cpu_set_t *set2);
> FreeBSD has these extra:
>    void CPU_FILL(cpu_set_t *set)
>    bool CPU_EMPTY(cpu_set_t *set) /* is empty? */
>    bool CPU_SUBSET(cpu_set_t *p,cpu_set_t *c) /* is c a subset of p? */
>    bool CPU_OVERLAP(cpu_set_t *p,cpu_set_t *c) /* do c and p overlap? */
> And these differ between FreeBSD and Linux. The Linux API has three
> parameters and is performs bitwise operations on the two sources
> and puts the result in destination. FreeBSD has an "|=" or "&="
> and takes destination and the set to operate with. This is the
> Linux API. Just drop a parameter to get FreeBSD but that makes
> them incompatible.
>    void CPU_AND(cpu_set_t *destset,
>       cpu_set_t *srcset1, cpu_set_t *srcset2);
>    void CPU_OR(cpu_set_t *destset,
>       cpu_set_t *srcset1, cpu_set_t *srcset2);
>    void CPU_XOR(cpu_set_t *destset,
>       cpu_set_t *srcset1, cpu_set_t *srcset2);
> FreeBSD also has NAND.
> Comments, suggestions, thoughts welcomed.

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 at embedded-brains.de
PGP     : Public key available on request.

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

More information about the devel mailing list