diff options
Diffstat (limited to '')
-rw-r--r-- | c/src/exec/posix/src/pthread.c | 10 | ||||
-rw-r--r-- | c/src/exec/score/headers/thread.h | 3 | ||||
-rw-r--r-- | c/src/exec/score/include/rtems/score/thread.h | 3 | ||||
-rw-r--r-- | c/src/exec/score/src/coremutex.c | 16 | ||||
-rw-r--r-- | c/src/exec/score/src/thread.c | 33 | ||||
-rw-r--r-- | cpukit/posix/src/pthread.c | 10 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/thread.h | 3 | ||||
-rw-r--r-- | cpukit/score/src/coremutex.c | 16 | ||||
-rw-r--r-- | cpukit/score/src/thread.c | 33 |
9 files changed, 98 insertions, 29 deletions
diff --git a/c/src/exec/posix/src/pthread.c b/c/src/exec/posix/src/pthread.c index 5864c22072..b4c1e7e1f4 100644 --- a/c/src/exec/posix/src/pthread.c +++ b/c/src/exec/posix/src/pthread.c @@ -77,7 +77,7 @@ void _POSIX_Threads_Sporadic_budget_TSR( if ( the_thread->resource_count == 0 || the_thread->current_priority > new_priority ) - _Thread_Change_priority( the_thread, new_priority ); + _Thread_Change_priority( the_thread, new_priority, TRUE ); ticks = _POSIX_Timespec_to_interval( &api->schedparam.ss_replenish_period ); @@ -114,7 +114,7 @@ void _POSIX_Threads_Sporadic_budget_callout( if ( the_thread->resource_count == 0 || the_thread->current_priority > new_priority ) - _Thread_Change_priority( the_thread, new_priority ); + _Thread_Change_priority( the_thread, new_priority, TRUE ); } /*PAGE @@ -656,7 +656,11 @@ int pthread_setschedparam( the_thread->real_priority = _POSIX_Priority_To_core( api->schedparam.sched_priority ); - _Thread_Change_priority( the_thread, the_thread->real_priority ); + _Thread_Change_priority( + the_thread, + the_thread->real_priority, + TRUE + ); break; case SCHED_SPORADIC: diff --git a/c/src/exec/score/headers/thread.h b/c/src/exec/score/headers/thread.h index c157f9b712..e50b05f80c 100644 --- a/c/src/exec/score/headers/thread.h +++ b/c/src/exec/score/headers/thread.h @@ -561,7 +561,8 @@ void _Thread_Delay_ended( void _Thread_Change_priority ( Thread_Control *the_thread, - Priority_Control new_priority + Priority_Control new_priority, + boolean prepend_it ); /* diff --git a/c/src/exec/score/include/rtems/score/thread.h b/c/src/exec/score/include/rtems/score/thread.h index c157f9b712..e50b05f80c 100644 --- a/c/src/exec/score/include/rtems/score/thread.h +++ b/c/src/exec/score/include/rtems/score/thread.h @@ -561,7 +561,8 @@ void _Thread_Delay_ended( void _Thread_Change_priority ( Thread_Control *the_thread, - Priority_Control new_priority + Priority_Control new_priority, + boolean prepend_it ); /* diff --git a/c/src/exec/score/src/coremutex.c b/c/src/exec/score/src/coremutex.c index f68d038e76..ffe3de6676 100644 --- a/c/src/exec/score/src/coremutex.c +++ b/c/src/exec/score/src/coremutex.c @@ -142,7 +142,8 @@ void _CORE_mutex_Seize( executing->current_priority ) { _Thread_Change_priority( the_mutex->holder, - the_mutex->Attributes.priority_ceiling + the_mutex->Attributes.priority_ceiling, + FALSE ); } } @@ -180,7 +181,8 @@ void _CORE_mutex_Seize( if ( the_mutex->holder->current_priority > executing->current_priority ) { _Thread_Change_priority( the_mutex->holder, - executing->current_priority + executing->current_priority, + FALSE ); } break; @@ -199,7 +201,8 @@ void _CORE_mutex_Seize( executing->current_priority ) { _Thread_Change_priority( executing, - the_mutex->Attributes.priority_ceiling + the_mutex->Attributes.priority_ceiling, + FALSE ); }; break; @@ -262,10 +265,9 @@ CORE_mutex_Status _CORE_mutex_Surrender( break; case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: - if ( executing->resource_count == 0 && - executing->real_priority != - executing->current_priority ) { - _Thread_Change_priority( executing, executing->real_priority ); + if ( executing->resource_count == 0 && + executing->real_priority != executing->current_priority ) { + _Thread_Change_priority( executing, executing->real_priority, TRUE ); } break; } diff --git a/c/src/exec/score/src/thread.c b/c/src/exec/score/src/thread.c index 517b0a077a..18984b6d9a 100644 --- a/c/src/exec/score/src/thread.c +++ b/c/src/exec/score/src/thread.c @@ -1206,6 +1206,7 @@ void _Thread_Delay_ended( * Input parameters: * the_thread - pointer to thread control block * new_priority - ultimate priority + * prepend_it - TRUE if the thread should be prepended to the chain * * Output parameters: NONE * @@ -1216,11 +1217,35 @@ void _Thread_Delay_ended( void _Thread_Change_priority( Thread_Control *the_thread, - Priority_Control new_priority + Priority_Control new_priority, + boolean prepend_it ) { ISR_Level level; + /* boolean do_prepend = FALSE; */ + /* + * If this is a case where prepending the task to its priority is + * potentially desired, then we need to consider whether to do it. + * This usually occurs when a task lowers its priority implcitly as + * the result of losing inherited priority. Normal explicit priority + * change calls (e.g. rtems_task_set_priority) should always do an + * append not a prepend. + */ + + /* + * Techically, the prepend should conditional on the thread lowering + * its priority but that does allow cxd2004 of the acvc 2.0.1 to + * pass with rtems 4.0.0. This should change when gnat redoes its + * priority scheme. + */ +/* + if ( prepend_it && + _Thread_Is_executing( the_thread ) && + new_priority >= the_thread->current_priority ) + prepend_it = TRUE; +*/ + _Thread_Set_transient( the_thread ); if ( the_thread->current_priority != new_priority ) @@ -1237,7 +1262,10 @@ void _Thread_Change_priority( } _Priority_Add_to_bit_map( &the_thread->Priority_map ); - _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node ); + if ( prepend_it ) + _Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node ); + else + _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node ); _ISR_Flash( level ); @@ -1246,7 +1274,6 @@ void _Thread_Change_priority( if ( !_Thread_Is_executing_also_the_heir() && _Thread_Executing->is_preemptible ) _Context_Switch_necessary = TRUE; - _ISR_Enable( level ); } diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c index 5864c22072..b4c1e7e1f4 100644 --- a/cpukit/posix/src/pthread.c +++ b/cpukit/posix/src/pthread.c @@ -77,7 +77,7 @@ void _POSIX_Threads_Sporadic_budget_TSR( if ( the_thread->resource_count == 0 || the_thread->current_priority > new_priority ) - _Thread_Change_priority( the_thread, new_priority ); + _Thread_Change_priority( the_thread, new_priority, TRUE ); ticks = _POSIX_Timespec_to_interval( &api->schedparam.ss_replenish_period ); @@ -114,7 +114,7 @@ void _POSIX_Threads_Sporadic_budget_callout( if ( the_thread->resource_count == 0 || the_thread->current_priority > new_priority ) - _Thread_Change_priority( the_thread, new_priority ); + _Thread_Change_priority( the_thread, new_priority, TRUE ); } /*PAGE @@ -656,7 +656,11 @@ int pthread_setschedparam( the_thread->real_priority = _POSIX_Priority_To_core( api->schedparam.sched_priority ); - _Thread_Change_priority( the_thread, the_thread->real_priority ); + _Thread_Change_priority( + the_thread, + the_thread->real_priority, + TRUE + ); break; case SCHED_SPORADIC: diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h index c157f9b712..e50b05f80c 100644 --- a/cpukit/score/include/rtems/score/thread.h +++ b/cpukit/score/include/rtems/score/thread.h @@ -561,7 +561,8 @@ void _Thread_Delay_ended( void _Thread_Change_priority ( Thread_Control *the_thread, - Priority_Control new_priority + Priority_Control new_priority, + boolean prepend_it ); /* diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c index f68d038e76..ffe3de6676 100644 --- a/cpukit/score/src/coremutex.c +++ b/cpukit/score/src/coremutex.c @@ -142,7 +142,8 @@ void _CORE_mutex_Seize( executing->current_priority ) { _Thread_Change_priority( the_mutex->holder, - the_mutex->Attributes.priority_ceiling + the_mutex->Attributes.priority_ceiling, + FALSE ); } } @@ -180,7 +181,8 @@ void _CORE_mutex_Seize( if ( the_mutex->holder->current_priority > executing->current_priority ) { _Thread_Change_priority( the_mutex->holder, - executing->current_priority + executing->current_priority, + FALSE ); } break; @@ -199,7 +201,8 @@ void _CORE_mutex_Seize( executing->current_priority ) { _Thread_Change_priority( executing, - the_mutex->Attributes.priority_ceiling + the_mutex->Attributes.priority_ceiling, + FALSE ); }; break; @@ -262,10 +265,9 @@ CORE_mutex_Status _CORE_mutex_Surrender( break; case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: - if ( executing->resource_count == 0 && - executing->real_priority != - executing->current_priority ) { - _Thread_Change_priority( executing, executing->real_priority ); + if ( executing->resource_count == 0 && + executing->real_priority != executing->current_priority ) { + _Thread_Change_priority( executing, executing->real_priority, TRUE ); } break; } diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c index 517b0a077a..18984b6d9a 100644 --- a/cpukit/score/src/thread.c +++ b/cpukit/score/src/thread.c @@ -1206,6 +1206,7 @@ void _Thread_Delay_ended( * Input parameters: * the_thread - pointer to thread control block * new_priority - ultimate priority + * prepend_it - TRUE if the thread should be prepended to the chain * * Output parameters: NONE * @@ -1216,11 +1217,35 @@ void _Thread_Delay_ended( void _Thread_Change_priority( Thread_Control *the_thread, - Priority_Control new_priority + Priority_Control new_priority, + boolean prepend_it ) { ISR_Level level; + /* boolean do_prepend = FALSE; */ + /* + * If this is a case where prepending the task to its priority is + * potentially desired, then we need to consider whether to do it. + * This usually occurs when a task lowers its priority implcitly as + * the result of losing inherited priority. Normal explicit priority + * change calls (e.g. rtems_task_set_priority) should always do an + * append not a prepend. + */ + + /* + * Techically, the prepend should conditional on the thread lowering + * its priority but that does allow cxd2004 of the acvc 2.0.1 to + * pass with rtems 4.0.0. This should change when gnat redoes its + * priority scheme. + */ +/* + if ( prepend_it && + _Thread_Is_executing( the_thread ) && + new_priority >= the_thread->current_priority ) + prepend_it = TRUE; +*/ + _Thread_Set_transient( the_thread ); if ( the_thread->current_priority != new_priority ) @@ -1237,7 +1262,10 @@ void _Thread_Change_priority( } _Priority_Add_to_bit_map( &the_thread->Priority_map ); - _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node ); + if ( prepend_it ) + _Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node ); + else + _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node ); _ISR_Flash( level ); @@ -1246,7 +1274,6 @@ void _Thread_Change_priority( if ( !_Thread_Is_executing_also_the_heir() && _Thread_Executing->is_preemptible ) _Context_Switch_necessary = TRUE; - _ISR_Enable( level ); } |