summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pthreadcreate.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-06-22 17:09:23 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-09-21 08:59:26 +0200
commit300f6a481aaf9e6d29811faca71bf7104a01492c (patch)
treeba8f18cedb93e3781a2f17aa989c5c805dd18d6a /cpukit/posix/src/pthreadcreate.c
parentclassic networking: do not reference BSP_irq_enabled_at_i8259s which is no mo... (diff)
downloadrtems-300f6a481aaf9e6d29811faca71bf7104a01492c.tar.bz2
score: Rework thread priority management
Add priority nodes which contribute to the overall thread priority. The actual priority of a thread is now an aggregation of priority nodes. The thread priority aggregation for the home scheduler instance of a thread consists of at least one priority node, which is normally the real priority of the thread. The locking protocols (e.g. priority ceiling and priority inheritance), rate-monotonic period objects and the POSIX sporadic server add, change and remove priority nodes. A thread changes its priority now immediately, e.g. priority changes are not deferred until the thread releases its last resource. Replace the _Thread_Change_priority() function with * _Thread_Priority_perform_actions(), * _Thread_Priority_add(), * _Thread_Priority_remove(), * _Thread_Priority_change(), and * _Thread_Priority_update(). Update #2412. Update #2556.
Diffstat (limited to 'cpukit/posix/src/pthreadcreate.c')
-rw-r--r--cpukit/posix/src/pthreadcreate.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index 411882d532..f1983ac128 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -61,11 +61,11 @@ int pthread_create(
}
};
const pthread_attr_t *the_attr;
+ int normal_prio;
int low_prio;
- int high_prio;
bool valid;
+ Priority_Control core_normal_prio;
Priority_Control core_low_prio;
- Priority_Control core_high_prio;
Thread_CPU_budget_algorithms budget_algorithm;
Thread_CPU_budget_algorithm_callout budget_callout;
bool is_fp;
@@ -149,22 +149,22 @@ int pthread_create(
return error;
}
- if ( schedpolicy == SCHED_SPORADIC ) {
- low_prio = schedparam.sched_ss_low_priority;
- high_prio = schedparam.sched_priority;
- } else {
- low_prio = schedparam.sched_priority;
- high_prio = low_prio;
- }
+ normal_prio = schedparam.sched_priority;
scheduler = _Scheduler_Get_own( executing );
- core_low_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_high_prio = _POSIX_Priority_To_core( scheduler, high_prio, &valid );
+ if ( schedpolicy == SCHED_SPORADIC ) {
+ low_prio = schedparam.sched_ss_low_priority;
+ } else {
+ low_prio = normal_prio;
+ }
+
+ core_low_prio = _POSIX_Priority_To_core( scheduler, low_prio, &valid );
if ( !valid ) {
return EINVAL;
}
@@ -205,7 +205,7 @@ int pthread_create(
the_attr->stackaddr,
_POSIX_Threads_Ensure_minimum_stack(the_attr->stacksize),
is_fp,
- core_high_prio,
+ core_normal_prio,
true, /* preemptible */
budget_algorithm,
budget_callout,
@@ -245,13 +245,11 @@ int pthread_create(
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
_POSIX_Threads_Copy_attributes( &api->Attributes, the_attr );
- api->Sporadic.low_priority = core_low_prio;
- api->Sporadic.high_priority = core_high_prio;
+ _Priority_Node_initialize( &api->Sporadic.Low_priority, core_low_prio );
+ _Priority_Node_set_inactive( &api->Sporadic.Low_priority );
if ( schedpolicy == SCHED_SPORADIC ) {
- _ISR_lock_ISR_disable( &lock_context );
- _POSIX_Threads_Sporadic_timer_insert( the_thread, api );
- _ISR_lock_ISR_enable( &lock_context );
+ _POSIX_Threads_Sporadic_timer( &api->Sporadic.Timer );
}
/*