diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-11-08 14:37:35 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-11-09 08:12:11 +0100 |
commit | 7147dc43b874271a0d4c14bbbc8ea10d1ed57cef (patch) | |
tree | 75c26dd9ef681f3558c6f96982e22a22454e2513 /cpukit/posix/src/pthreadgetattrnp.c | |
parent | sptests/spconsole01: New test (diff) | |
download | rtems-7147dc43b874271a0d4c14bbbc8ea10d1ed57cef.tar.bz2 |
posix: Remove POSIX_API_Control::schedpolicy
Use the thread CPU budget algorithm to determine the scheduler policy.
This fixes also pthread_getschedparam() for Classic tasks.
Update #2514.
Diffstat (limited to 'cpukit/posix/src/pthreadgetattrnp.c')
-rw-r--r-- | cpukit/posix/src/pthreadgetattrnp.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/cpukit/posix/src/pthreadgetattrnp.c b/cpukit/posix/src/pthreadgetattrnp.c index bebf35e4d6..9df5bad38f 100644 --- a/cpukit/posix/src/pthreadgetattrnp.c +++ b/cpukit/posix/src/pthreadgetattrnp.c @@ -34,11 +34,12 @@ int pthread_getattr_np( pthread_attr_t *attr ) { - Thread_Control *the_thread; - ISR_lock_Context lock_context; - POSIX_API_Control *api; - const Scheduler_Control *scheduler; - bool ok; + Thread_Control *the_thread; + ISR_lock_Context lock_context; + const POSIX_API_Control *api; + Thread_CPU_budget_algorithms budget_algorithm; + const Scheduler_Control *scheduler; + bool ok; if ( attr == NULL ) { return EINVAL; @@ -56,10 +57,8 @@ int pthread_getattr_np( api = the_thread->API_Extensions[ THREAD_API_POSIX ]; - attr->is_initialized = true; attr->stackaddr = the_thread->Start.Initial_stack.area; attr->stacksize = the_thread->Start.Initial_stack.size; - attr->contentionscope = PTHREAD_SCOPE_PROCESS; if ( api->created_with_explicit_scheduler ) { attr->inheritsched = PTHREAD_EXPLICIT_SCHED; @@ -67,8 +66,6 @@ int pthread_getattr_np( attr->inheritsched = PTHREAD_INHERIT_SCHED; } - attr->schedpolicy = api->schedpolicy; - scheduler = _Thread_Scheduler_get_home( the_thread ); attr->schedparam.sched_priority = _POSIX_Priority_From_core( scheduler, @@ -80,7 +77,6 @@ int pthread_getattr_np( scheduler, &attr->schedparam ); - attr->cputime_clock_allowed = 1; if ( _Thread_Is_joinable( the_thread ) ) { attr->detachstate = PTHREAD_CREATE_JOINABLE; @@ -96,6 +92,15 @@ int pthread_getattr_np( attr->affinityset ); + budget_algorithm = the_thread->budget_algorithm; + _Thread_State_release( the_thread, &lock_context ); + + attr->is_initialized = true; + attr->contentionscope = PTHREAD_SCOPE_PROCESS; + attr->cputime_clock_allowed = 1; + attr->schedpolicy = + _POSIX_Thread_Translate_to_sched_policy( budget_algorithm ); + return ok ? 0 : EINVAL; } |