RFCL cpuset APIs

Gedare Bloom gedare at rtems.org
Sat Oct 12 00:27:46 UTC 2013


How much code are we talking about here? I would lean toward a clean
RTEMS implementation. Is this going to be implemented in the score?

-Gedare

On Fri, Oct 11, 2013 at 5:06 PM, Joel Sherrill
<joel.sherrill at oarcorp.com> 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.
>
>
> --
> Joel Sherrill, Ph.D.             Director of Research & Development
> joel.sherrill at OARcorp.com        On-Line Applications Research
> Ask me about RTEMS: a free RTOS  Huntsville AL 35805
> Support Available                (256) 722-9985
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel



More information about the devel mailing list