From 3f3f42482daa45aff3647f34afb4e2c4eca242cd Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 17 Oct 2017 09:20:20 +0200 Subject: posix: Remove POSIX_API_Control::schedparam Move sporadic server scheduler parameters to POSIX_API_Control::Sporadic. Remove redundant scheduler priority parameter. Update #2514. --- cpukit/posix/src/pthread.c | 6 ------ cpukit/posix/src/pthreadcreate.c | 8 +++++++- cpukit/posix/src/pthreadgetattrnp.c | 24 +++++++++++++++++++----- cpukit/posix/src/pthreadgetschedparam.c | 4 ++-- cpukit/posix/src/pthreadsetschedparam.c | 27 +++++++++++++++------------ 5 files changed, 43 insertions(+), 26 deletions(-) (limited to 'cpukit/posix/src') diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c index 291b19532d..8bd44ca03a 100644 --- a/cpukit/posix/src/pthread.c +++ b/cpukit/posix/src/pthread.c @@ -126,12 +126,6 @@ static bool _POSIX_Threads_Create_extension( api = created->API_Extensions[ THREAD_API_POSIX ]; - /* XXX check all fields are touched */ - api->schedparam.sched_priority = _POSIX_Priority_From_core( - _Thread_Scheduler_get_home( created ), - _Thread_Get_priority( created ) - ); - /* * If the thread is not a posix thread, then all posix signals are blocked * by default. diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c index d8cafe52ce..0de566f7c2 100644 --- a/cpukit/posix/src/pthreadcreate.c +++ b/cpukit/posix/src/pthreadcreate.c @@ -241,8 +241,14 @@ int pthread_create( api->created_with_explicit_scheduler = ( the_attr->inheritsched == PTHREAD_EXPLICIT_SCHED ); api->schedpolicy = the_attr->schedpolicy; - api->schedparam = the_attr->schedparam; + _Priority_Node_set_priority( &api->Sporadic.Low_priority, core_low_prio ); + api->Sporadic.sched_ss_repl_period = + the_attr->schedparam.sched_ss_repl_period; + api->Sporadic.sched_ss_init_budget = + the_attr->schedparam.sched_ss_init_budget; + api->Sporadic.sched_ss_max_repl = + the_attr->schedparam.sched_ss_max_repl; if ( schedpolicy == SCHED_SPORADIC ) { _POSIX_Threads_Sporadic_timer( &api->Sporadic.Timer ); diff --git a/cpukit/posix/src/pthreadgetattrnp.c b/cpukit/posix/src/pthreadgetattrnp.c index d815fc8c53..bebf35e4d6 100644 --- a/cpukit/posix/src/pthreadgetattrnp.c +++ b/cpukit/posix/src/pthreadgetattrnp.c @@ -24,6 +24,8 @@ #include #include +#include +#include #include #include @@ -32,10 +34,11 @@ int pthread_getattr_np( pthread_attr_t *attr ) { - Thread_Control *the_thread; - ISR_lock_Context lock_context; - POSIX_API_Control *api; - bool ok; + Thread_Control *the_thread; + ISR_lock_Context lock_context; + POSIX_API_Control *api; + const Scheduler_Control *scheduler; + bool ok; if ( attr == NULL ) { return EINVAL; @@ -65,7 +68,18 @@ int pthread_getattr_np( } attr->schedpolicy = api->schedpolicy; - attr->schedparam = api->schedparam; + + scheduler = _Thread_Scheduler_get_home( the_thread ); + attr->schedparam.sched_priority = _POSIX_Priority_From_core( + scheduler, + _Thread_Get_priority( the_thread ) + ); + _POSIX_Threads_Get_sched_param_sporadic( + the_thread, + api, + scheduler, + &attr->schedparam + ); attr->cputime_clock_allowed = 1; if ( _Thread_Is_joinable( the_thread ) ) { diff --git a/cpukit/posix/src/pthreadgetschedparam.c b/cpukit/posix/src/pthreadgetschedparam.c index f172caecd4..a5494b5922 100644 --- a/cpukit/posix/src/pthreadgetschedparam.c +++ b/cpukit/posix/src/pthreadgetschedparam.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -57,9 +58,8 @@ int pthread_getschedparam( _Thread_Wait_acquire_critical( the_thread, &queue_context ); *policy = api->schedpolicy; - *param = api->schedparam; - scheduler = _Thread_Scheduler_get_home( the_thread ); + _POSIX_Threads_Get_sched_param_sporadic( the_thread, api, scheduler, param ); priority = the_thread->Real_priority.priority; _Thread_Wait_release( the_thread, &queue_context ); diff --git a/cpukit/posix/src/pthreadsetschedparam.c b/cpukit/posix/src/pthreadsetschedparam.c index 3bd5bc4f3a..c22d4f59b1 100644 --- a/cpukit/posix/src/pthreadsetschedparam.c +++ b/cpukit/posix/src/pthreadsetschedparam.c @@ -41,28 +41,28 @@ static int _POSIX_Set_sched_param( { const Scheduler_Control *scheduler; POSIX_API_Control *api; + int normal_prio; int low_prio; - int high_prio; bool valid; Priority_Control core_normal_prio; Priority_Control core_low_prio; - if ( policy == SCHED_SPORADIC ) { - low_prio = param->sched_ss_low_priority; - high_prio = param->sched_priority; - } else { - low_prio = param->sched_priority; - high_prio = low_prio; - } + normal_prio = param->sched_priority; scheduler = _Thread_Scheduler_get_home( the_thread ); - core_normal_prio = _POSIX_Priority_To_core( scheduler, low_prio, &valid ); + core_normal_prio = _POSIX_Priority_To_core( scheduler, normal_prio, &valid ); if ( !valid ) { return EINVAL; } - core_low_prio = _POSIX_Priority_To_core( scheduler, high_prio, &valid ); + if ( policy == SCHED_SPORADIC ) { + low_prio = param->sched_ss_low_priority; + } else { + low_prio = normal_prio; + } + + core_low_prio = _POSIX_Priority_To_core( scheduler, low_prio, &valid ); if ( !valid ) { return EINVAL; } @@ -95,13 +95,16 @@ static int _POSIX_Set_sched_param( } api->schedpolicy = policy; - api->schedparam = *param; the_thread->budget_algorithm = budget_algorithm; the_thread->budget_callout = budget_callout; + _Priority_Node_set_priority( &api->Sporadic.Low_priority, core_low_prio ); + api->Sporadic.sched_ss_repl_period = param->sched_ss_repl_period; + api->Sporadic.sched_ss_init_budget = param->sched_ss_init_budget; + api->Sporadic.sched_ss_max_repl = param->sched_ss_max_repl; + if ( policy == SCHED_SPORADIC ) { - _Priority_Node_set_priority( &api->Sporadic.Low_priority, core_low_prio ); _POSIX_Threads_Sporadic_timer_insert( the_thread, api ); } else { the_thread->cpu_time_budget = -- cgit v1.2.3