<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style></head>
<body>
<body><p dir="ltr">Gedare.. </p><p dir="ltr">We discussed this privately when you raised this to me. It should not be part of the scheduler per thread data. lf you do then the data just disappears from the API perspective when the scheduler doesn't support affinity. It will create a new class of odd errors at the API level which no other implementation of this type of API has. From an API perspective, it is the same as the preempt and timeslicing flags.</p><p dir="ltr">It is disabled in non-smp configurations, so doesn't impact minimum footprint.</p><p dir="ltr">I seriously considered this and decided it was a bad idea. I don't know if I have veto power :) but if I did, I would invoke it here.</p><p dir="ltr">We can revisit this when we have a scheduler with affinity. As it stands now, there is absolutely no way to test any of this code if we move the affinity data to the scheduler.</p><div class="quote">On Mar 5, 2014 7:21 AM, Gedare Bloom <gedare@rtems.org> wrote:<br type="attribution"></div></body>
<font size="2"><div class="PlainText">I agree with Sebastian. I raised this issue on the other patch that<br>
modifies the TCB to include the Cpuset_Control affinity field. That<br>
field should be part of the scheduler's per-thread metadata.<br>
<br>
On Wed, Mar 5, 2014 at 2:25 AM, Sebastian Huber<br>
<sebastian.huber@embedded-brains.de> wrote:<br>
> On 2014-02-27 14:28, Jennifer Averett wrote:<br>
>><br>
>> +int pthread_setaffinity_np(<br>
>> + pthread_t id,<br>
>> + size_t cpusetsize,<br>
>> + const cpu_set_t *cpuset)<br>
>> +{<br>
>> + Objects_Locations location;<br>
>> + POSIX_API_Control *api;<br>
>> + Thread_Control *the_thread;<br>
>> + int error;<br>
>> +<br>
>> + if ( !cpuset )<br>
>> + return EFAULT;<br>
>> +<br>
>> + error = _CPU_set_Is_valid( cpuset, cpusetsize );<br>
>> + if ( error != 0 )<br>
>> + return EINVAL;<br>
>> +<br>
>> + the_thread = _Thread_Get( id, &location );<br>
>> + switch ( location ) {<br>
>> +<br>
>> + case OBJECTS_LOCAL:<br>
>> + api = the_thread->API_Extensions[ THREAD_API_POSIX ];<br>
>> + CPU_COPY( the_thread->affinity.set, cpuset );<br>
>> + CPU_COPY( api->Attributes.affinityset, cpuset );<br>
>> + _Objects_Put( &the_thread->Object );<br>
>> + return 0;<br>
>> + break;<br>
>> +<br>
>> +#if defined(RTEMS_MULTIPROCESSING)<br>
>> + case OBJECTS_REMOTE:<br>
>> +#endif<br>
>> + case OBJECTS_ERROR:<br>
>> + break;<br>
>> + }<br>
>> +<br>
>> + return ESRCH;<br>
>> +}<br>
><br>
><br>
> Sorry, for the late answer, but I think this approach makes no sense.<br>
><br>
> Your pthread_setaffinity_np() implementation just copies some bits from A to<br>
> B. I think that the thread processor affinity is independent of the API<br>
> (Classic, POSIX, Internal). So the storage space for the affinity set<br>
> should not be in "api->Attributes". The scheduler should know about an<br>
> affinity set change, so here we need a scheduler operation invocation.<br>
><br>
> <a href="http://www.rtems.org/wiki/index.php?title=SMP#Scheduler_Implementation">http://www.rtems.org/wiki/index.php?title=SMP#Scheduler_Implementation</a><br>
><br>
> Since the scheduler knows best what do it should also store the affinity set<br>
> in its per-thread control block, e.g. in the stuff allocated via<br>
><br>
> /**<br>
> * @brief Scheduler allocate.<br>
> *<br>
> * This routine allocates @a the_thread->scheduler<br>
> */<br>
> RTEMS_INLINE_ROUTINE void* _Scheduler_Allocate(<br>
> Thread_Control *the_thread<br>
> )<br>
> {<br>
> return _Scheduler.Operations.allocate( the_thread );<br>
> }<br>
><br>
> The scheduler can then use the optimal data structure for its algorithms.<br>
> Since all currently implemented schedulers in RTEMS don't support thread<br>
> affinity this is particularly easy, they only have to check the affinity set<br>
> and need to store nothing.<br>
><br>
> This makes also _CPU_set_Is_valid() superfluous since the scheduler is then<br>
> responsible to check the affinity set.<br>
><br>
> --<br>
> Sebastian Huber, embedded brains GmbH<br>
><br>
> Address : Dornierstr. 4, D-82178 Puchheim, Germany<br>
> Phone : +49 89 189 47 41-16<br>
> Fax : +49 89 189 47 41-09<br>
> E-Mail : sebastian.huber@embedded-brains.de<br>
> PGP : Public key available on request.<br>
><br>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<br>
><br>
> _______________________________________________<br>
> rtems-devel mailing list<br>
> rtems-devel@rtems.org<br>
> <a href="http://www.rtems.org/mailman/listinfo/rtems-devel">http://www.rtems.org/mailman/listinfo/rtems-devel</a><br>
<br>
_______________________________________________<br>
rtems-devel mailing list<br>
rtems-devel@rtems.org<br>
<a href="http://www.rtems.org/mailman/listinfo/rtems-devel">http://www.rtems.org/mailman/listinfo/rtems-devel</a><br>
</div></font>
</body>
</html>