forked from Imagelibrary/rtems
posix: Move affinity from thread to scheduler.
This commit is contained in:
@@ -42,8 +42,7 @@ int pthread_attr_setaffinity_np(
|
||||
if ( !attr )
|
||||
return EFAULT;
|
||||
|
||||
error = _CPU_set_Is_valid( cpuset, cpusetsize );
|
||||
if ( error != 0 )
|
||||
if (! _CPU_set_Is_valid( cpuset, cpusetsize ) )
|
||||
return EINVAL;
|
||||
|
||||
CPU_COPY( attr->affinityset, cpuset );
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#include <rtems/score/apimutex.h>
|
||||
#include <rtems/score/stackimpl.h>
|
||||
#include <rtems/score/watchdogimpl.h>
|
||||
#include <rtems/score/schedulerimpl.h>
|
||||
|
||||
|
||||
static inline size_t _POSIX_Threads_Ensure_minimum_stack (
|
||||
size_t size
|
||||
@@ -139,8 +141,8 @@ int pthread_create(
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
#if __RTEMS_HAVE_SYS_CPUSET_H__
|
||||
rc = _CPU_set_Is_valid( the_attr->affinityset, the_attr->affinitysetsize );
|
||||
if ( rc != 0 )
|
||||
status = _CPU_set_Is_valid( the_attr->affinityset, the_attr->affinitysetsize );
|
||||
if (!status )
|
||||
return EINVAL;
|
||||
#endif
|
||||
#endif
|
||||
@@ -191,8 +193,16 @@ int pthread_create(
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
#if __RTEMS_HAVE_SYS_CPUSET_H__
|
||||
the_thread->affinity.setsize = the_attr->affinitysetsize;
|
||||
*the_thread->affinity.set = *the_attr->affinityset;
|
||||
status = _Scheduler_Set_affinity(
|
||||
the_thread,
|
||||
attr->affinitysetsize,
|
||||
attr->affinityset
|
||||
);
|
||||
if ( !status ) {
|
||||
_POSIX_Threads_Free( the_thread );
|
||||
_RTEMS_Unlock_allocator();
|
||||
return EINVAL;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <rtems/posix/pthreadimpl.h>
|
||||
#include <rtems/posix/priorityimpl.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#include <rtems/score/schedulerimpl.h>
|
||||
|
||||
int pthread_getaffinity_np(
|
||||
const pthread_t id,
|
||||
@@ -37,7 +38,7 @@ int pthread_getaffinity_np(
|
||||
{
|
||||
Objects_Locations location;
|
||||
Thread_Control *the_thread;
|
||||
int error;
|
||||
bool ok;
|
||||
|
||||
if ( !cpuset )
|
||||
return EFAULT;
|
||||
@@ -46,14 +47,11 @@ int pthread_getaffinity_np(
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
error = 0;
|
||||
if ( cpusetsize != the_thread->affinity.setsize )
|
||||
error = EINVAL;
|
||||
else
|
||||
CPU_COPY( cpuset, the_thread->affinity.set );
|
||||
|
||||
ok = _Scheduler_Get_affinity( the_thread, cpusetsize, cpuset );
|
||||
_Objects_Put( &the_thread->Object );
|
||||
return error;
|
||||
if (!ok)
|
||||
return EINVAL;
|
||||
return 0;
|
||||
break;
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <rtems/posix/priorityimpl.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#include <rtems/score/cpusetimpl.h>
|
||||
#include <rtems/score/schedulerimpl.h>
|
||||
|
||||
int pthread_setaffinity_np(
|
||||
pthread_t id,
|
||||
@@ -37,23 +38,22 @@ int pthread_setaffinity_np(
|
||||
Objects_Locations location;
|
||||
POSIX_API_Control *api;
|
||||
Thread_Control *the_thread;
|
||||
int error;
|
||||
bool ok;
|
||||
|
||||
if ( !cpuset )
|
||||
return EFAULT;
|
||||
|
||||
error = _CPU_set_Is_valid( cpuset, cpusetsize );
|
||||
if ( error != 0 )
|
||||
return EINVAL;
|
||||
|
||||
the_thread = _Thread_Get( id, &location );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||
CPU_COPY( the_thread->affinity.set, cpuset );
|
||||
CPU_COPY( api->Attributes.affinityset, cpuset );
|
||||
ok = _Scheduler_Set_affinity( the_thread, cpusetsize, cpuset );
|
||||
if (ok)
|
||||
CPU_COPY( api->Attributes.affinityset, cpuset );
|
||||
_Objects_Put( &the_thread->Object );
|
||||
if (!ok)
|
||||
return EINVAL;
|
||||
return 0;
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user