From 24934e36e2513f972510d7c746103be1f766dc6a Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 3 Apr 2014 15:03:35 +0200 Subject: score: Add scheduler control to scheduler ops Scheduler operations must be free of a global scheduler context to enable partitioned/clustered scheduling. --- cpukit/posix/src/nanosleep.c | 2 +- cpukit/posix/src/pthreadcreate.c | 1 + cpukit/posix/src/pthreadgetaffinitynp.c | 12 +++++++----- cpukit/posix/src/pthreadsetaffinitynp.c | 17 ++++++++++------- cpukit/posix/src/sched_yield.c | 5 ++++- 5 files changed, 23 insertions(+), 14 deletions(-) (limited to 'cpukit/posix') diff --git a/cpukit/posix/src/nanosleep.c b/cpukit/posix/src/nanosleep.c index 52fcc96d6e..ebaef33b26 100644 --- a/cpukit/posix/src/nanosleep.c +++ b/cpukit/posix/src/nanosleep.c @@ -65,7 +65,7 @@ int nanosleep( if ( !ticks ) { _Thread_Disable_dispatch(); executing = _Thread_Executing; - _Scheduler_Yield( executing ); + _Scheduler_Yield( _Scheduler_Get( executing ), executing ); _Thread_Enable_dispatch(); if ( rmtp ) { rmtp->tv_sec = 0; diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c index 8ae790480b..f85e1efcfd 100644 --- a/cpukit/posix/src/pthreadcreate.c +++ b/cpukit/posix/src/pthreadcreate.c @@ -194,6 +194,7 @@ int pthread_create( #if defined(RTEMS_SMP) && __RTEMS_HAVE_SYS_CPUSET_H__ status = _Scheduler_Set_affinity( + _Scheduler_Get( the_thread ), the_thread, the_attr->affinitysetsize, the_attr->affinityset diff --git a/cpukit/posix/src/pthreadgetaffinitynp.c b/cpukit/posix/src/pthreadgetaffinitynp.c index 497236f60f..41b8d30be2 100644 --- a/cpukit/posix/src/pthreadgetaffinitynp.c +++ b/cpukit/posix/src/pthreadgetaffinitynp.c @@ -47,12 +47,14 @@ int pthread_getaffinity_np( switch ( location ) { case OBJECTS_LOCAL: - ok = _Scheduler_Get_affinity( the_thread, cpusetsize, cpuset ); + ok = _Scheduler_Get_affinity( + _Scheduler_Get( the_thread ), + the_thread, + cpusetsize, + cpuset + ); _Objects_Put( &the_thread->Object ); - if (!ok) - return EINVAL; - return 0; - break; + return ok ? 0 : EINVAL; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: diff --git a/cpukit/posix/src/pthreadsetaffinitynp.c b/cpukit/posix/src/pthreadsetaffinitynp.c index d150b409a1..d9df75b8de 100644 --- a/cpukit/posix/src/pthreadsetaffinitynp.c +++ b/cpukit/posix/src/pthreadsetaffinitynp.c @@ -47,15 +47,18 @@ int pthread_setaffinity_np( switch ( location ) { case OBJECTS_LOCAL: - api = the_thread->API_Extensions[ THREAD_API_POSIX ]; - ok = _Scheduler_Set_affinity( the_thread, cpusetsize, cpuset ); - if (ok) + ok = _Scheduler_Set_affinity( + _Scheduler_Get( the_thread ), + the_thread, + cpusetsize, + cpuset + ); + if ( ok ) { + api = the_thread->API_Extensions[ THREAD_API_POSIX ]; CPU_COPY( api->Attributes.affinityset, cpuset ); + } _Objects_Put( &the_thread->Object ); - if (!ok) - return EINVAL; - return 0; - break; + return ok ? 0 : EINVAL; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: diff --git a/cpukit/posix/src/sched_yield.c b/cpukit/posix/src/sched_yield.c index 906d102a37..5293b199dc 100644 --- a/cpukit/posix/src/sched_yield.c +++ b/cpukit/posix/src/sched_yield.c @@ -26,8 +26,11 @@ int sched_yield( void ) { + Thread_Control *executing; + _Thread_Disable_dispatch(); - _Scheduler_Yield( _Thread_Executing ); + executing = _Thread_Executing; + _Scheduler_Yield( _Scheduler_Get( executing ), executing ); _Thread_Enable_dispatch(); return 0; } -- cgit v1.2.3