From b50468c6bff4e770aa038b9f87e514a2a1da906b Mon Sep 17 00:00:00 2001 From: Gedare Bloom Date: Thu, 21 Dec 2017 13:04:50 -0500 Subject: score: add Inherited_priorities priority queue and functions Adds enqueue, dequeue, requeue, evaluate, and release functions for the thread priority node priority queue of inherited priorities. Add calls to these functions as needed to maintain the priority queue due to blocking, unblocking, and priority changes. Closes #3359. --- cpukit/score/src/threadreset.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cpukit/score/src/threadreset.c') diff --git a/cpukit/score/src/threadreset.c b/cpukit/score/src/threadreset.c index fd55ca320f..464a611391 100644 --- a/cpukit/score/src/threadreset.c +++ b/cpukit/score/src/threadreset.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,8 @@ void _Thread_Reset( Thread_Entry_numeric_type numeric_argument ) { + CORE_mutex_Control *mutex; + the_thread->resource_count = 0; #if defined(RTEMS_ITRON_API) the_thread->suspend_count = 0; @@ -63,6 +66,19 @@ void _Thread_Reset( (void) _Watchdog_Remove( &the_thread->Timer ); } + if ( the_thread->Priority_node.waiting_to_hold != NULL ) { + mutex = _Thread_Dequeue_priority_node( &the_thread->Priority_node ); + _Thread_Evaluate_priority( mutex->holder ); + } + + while ( !_Chain_Is_empty( &the_thread->Priority_node.Inherited_priorities ) ) { + _Thread_Dequeue_priority_node( + ((Thread_Priority_node*)_Chain_First( + &the_thread->Priority_node.Inherited_priorities + )) + ); + } + if ( the_thread->Priority_node.current_priority != the_thread->Start.initial_priority ) { the_thread->Priority_node.real_priority = the_thread->Start.initial_priority; _Thread_Set_priority( the_thread, the_thread->Start.initial_priority ); -- cgit v1.2.3