From b8a5abf3fafa9df7cc0354c0ada6192c38e78354 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 26 Feb 2015 10:33:36 +0100 Subject: score: Update _Thread_Heir only if necessary Previously, the _Thread_Heir was updated unconditionally in case a new heir was determined. The _Thread_Dispatch_necessary was only updated in case the executing thread was preemptible or an internal thread was unblocked. Change this to update the _Thread_Heir and _Thread_Dispatch_necessary only in case the currently selected heir thread is preemptible or a dispatch is forced. Move the schedule decision into the change priority operation and use the schedule operation only in rtems_task_mode() in case preemption is enabled or an ASR dispatch is necessary. This is a behaviour change. Previously, the RTEMS_NO_PREEMPT also prevented signal delivery in certain cases (not always). Now, signal delivery is no longer influenced by RTEMS_NO_PREEMPT. Since the currently selected heir thread is used to determine if a new heir is chosen, non-preemptible heir threads currently not executing now prevent a new heir. This may have an application impact, see change test tm04. Document this change in sp04. Update #2273. --- cpukit/score/src/schedulercbsunblock.c | 8 ++++---- cpukit/score/src/scheduleredfchangepriority.c | 2 ++ cpukit/score/src/scheduleredfunblock.c | 8 ++++---- cpukit/score/src/schedulerprioritychangepriority.c | 2 ++ cpukit/score/src/schedulerpriorityunblock.c | 8 ++++---- cpukit/score/src/schedulerpriorityyield.c | 12 ++---------- cpukit/score/src/schedulersimplechangepriority.c | 2 ++ cpukit/score/src/schedulersimpleunblock.c | 8 ++++---- cpukit/score/src/threadchangepriority.c | 9 +-------- 9 files changed, 25 insertions(+), 34 deletions(-) (limited to 'cpukit/score/src') diff --git a/cpukit/score/src/schedulercbsunblock.c b/cpukit/score/src/schedulercbsunblock.c index 688253c279..56b35de8b9 100644 --- a/cpukit/score/src/schedulercbsunblock.c +++ b/cpukit/score/src/schedulercbsunblock.c @@ -79,10 +79,10 @@ Scheduler_Void_or_thread _Scheduler_CBS_Unblock( _Thread_Heir->current_priority ) ) { - _Thread_Heir = the_thread; - if ( _Thread_Executing->is_preemptible || - the_thread->current_priority == 0 ) - _Thread_Dispatch_necessary = true; + _Scheduler_Update_heir( + the_thread, + the_thread->current_priority == PRIORITY_PSEUDO_ISR + ); } SCHEDULER_RETURN_VOID_OR_NULL; diff --git a/cpukit/score/src/scheduleredfchangepriority.c b/cpukit/score/src/scheduleredfchangepriority.c index 3eabc83878..61e0481d03 100644 --- a/cpukit/score/src/scheduleredfchangepriority.c +++ b/cpukit/score/src/scheduleredfchangepriority.c @@ -39,5 +39,7 @@ Scheduler_Void_or_thread _Scheduler_EDF_Change_priority( false ); + _Scheduler_EDF_Schedule_body( scheduler, the_thread, false ); + SCHEDULER_RETURN_VOID_OR_NULL; } diff --git a/cpukit/score/src/scheduleredfunblock.c b/cpukit/score/src/scheduleredfunblock.c index 308a691e64..977534214c 100644 --- a/cpukit/score/src/scheduleredfunblock.c +++ b/cpukit/score/src/scheduleredfunblock.c @@ -46,10 +46,10 @@ Scheduler_Void_or_thread _Scheduler_EDF_Unblock( scheduler, _Thread_Heir->current_priority, the_thread->current_priority )) { - _Thread_Heir = the_thread; - if ( _Thread_Executing->is_preemptible || - the_thread->current_priority == 0 ) - _Thread_Dispatch_necessary = true; + _Scheduler_Update_heir( + the_thread, + the_thread->current_priority == PRIORITY_PSEUDO_ISR + ); } SCHEDULER_RETURN_VOID_OR_NULL; diff --git a/cpukit/score/src/schedulerprioritychangepriority.c b/cpukit/score/src/schedulerprioritychangepriority.c index 06c5f0f7c6..f883e02d43 100644 --- a/cpukit/score/src/schedulerprioritychangepriority.c +++ b/cpukit/score/src/schedulerprioritychangepriority.c @@ -59,5 +59,7 @@ Scheduler_Void_or_thread _Scheduler_priority_Change_priority( ); } + _Scheduler_priority_Schedule_body( scheduler, the_thread, false ); + SCHEDULER_RETURN_VOID_OR_NULL; } diff --git a/cpukit/score/src/schedulerpriorityunblock.c b/cpukit/score/src/schedulerpriorityunblock.c index 06d29f3b91..a912ebfbe2 100644 --- a/cpukit/score/src/schedulerpriorityunblock.c +++ b/cpukit/score/src/schedulerpriorityunblock.c @@ -52,10 +52,10 @@ Scheduler_Void_or_thread _Scheduler_priority_Unblock ( * a pseudo-ISR system task, we need to do a context switch. */ if ( the_thread->current_priority < _Thread_Heir->current_priority ) { - _Thread_Heir = the_thread; - if ( _Thread_Executing->is_preemptible || - the_thread->current_priority == 0 ) - _Thread_Dispatch_necessary = true; + _Scheduler_Update_heir( + the_thread, + the_thread->current_priority == PRIORITY_PSEUDO_ISR + ); } SCHEDULER_RETURN_VOID_OR_NULL; diff --git a/cpukit/score/src/schedulerpriorityyield.c b/cpukit/score/src/schedulerpriorityyield.c index 2ee2d03057..5dab094f46 100644 --- a/cpukit/score/src/schedulerpriorityyield.c +++ b/cpukit/score/src/schedulerpriorityyield.c @@ -29,20 +29,12 @@ Scheduler_Void_or_thread _Scheduler_priority_Yield( Scheduler_priority_Node *node = _Scheduler_priority_Thread_get_node( the_thread ); Chain_Control *ready_chain = node->Ready_queue.ready_chain; - (void) scheduler; - if ( !_Chain_Has_only_one_node( ready_chain ) ) { _Chain_Extract_unprotected( &the_thread->Object.Node ); _Chain_Append_unprotected( ready_chain, &the_thread->Object.Node ); - - if ( _Thread_Is_heir( the_thread ) ) { - _Thread_Heir = (Thread_Control *) _Chain_First( ready_chain ); - } - - _Thread_Dispatch_necessary = true; - } else if ( !_Thread_Is_heir( the_thread ) ) { - _Thread_Dispatch_necessary = true; } + _Scheduler_priority_Schedule_body( scheduler, the_thread, true ); + SCHEDULER_RETURN_VOID_OR_NULL; } diff --git a/cpukit/score/src/schedulersimplechangepriority.c b/cpukit/score/src/schedulersimplechangepriority.c index b8638ad28c..9b94b3ab26 100644 --- a/cpukit/score/src/schedulersimplechangepriority.c +++ b/cpukit/score/src/schedulersimplechangepriority.c @@ -39,5 +39,7 @@ Scheduler_Void_or_thread _Scheduler_simple_Change_priority( _Scheduler_simple_Insert_priority_fifo( &context->Ready, the_thread ); } + _Scheduler_simple_Schedule_body( scheduler, the_thread, false ); + SCHEDULER_RETURN_VOID_OR_NULL; } diff --git a/cpukit/score/src/schedulersimpleunblock.c b/cpukit/score/src/schedulersimpleunblock.c index 6f9b2f719f..a020f74767 100644 --- a/cpukit/score/src/schedulersimpleunblock.c +++ b/cpukit/score/src/schedulersimpleunblock.c @@ -44,10 +44,10 @@ Scheduler_Void_or_thread _Scheduler_simple_Unblock( * a pseudo-ISR system task, we need to do a context switch. */ if ( the_thread->current_priority < _Thread_Heir->current_priority ) { - _Thread_Heir = the_thread; - if ( _Thread_Executing->is_preemptible || - the_thread->current_priority == 0 ) - _Thread_Dispatch_necessary = true; + _Scheduler_Update_heir( + the_thread, + the_thread->current_priority == PRIORITY_PSEUDO_ISR + ); } SCHEDULER_RETURN_VOID_OR_NULL; diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c index ca2c5871af..d61dfb859a 100644 --- a/cpukit/score/src/threadchangepriority.c +++ b/cpukit/score/src/threadchangepriority.c @@ -46,17 +46,10 @@ void _Thread_Change_priority( new_priority, prepend_it ); - - _ISR_Flash( level ); - - /* - * We altered the set of thread priorities. So let's figure out - * who is the heir and if we need to switch to them. - */ - _Scheduler_Schedule( the_thread ); } else { _Scheduler_Update_priority( the_thread, new_priority ); } + _ISR_Enable( level ); _Thread_queue_Requeue( the_thread->Wait.queue, the_thread ); -- cgit v1.2.3