diff options
Diffstat (limited to 'cpukit/score/src/threadqflush.c')
-rw-r--r-- | cpukit/score/src/threadqflush.c | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/cpukit/score/src/threadqflush.c b/cpukit/score/src/threadqflush.c index 357e3d696e..a4ff20bb17 100644 --- a/cpukit/score/src/threadqflush.c +++ b/cpukit/score/src/threadqflush.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -14,9 +16,26 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H @@ -71,15 +90,15 @@ size_t _Thread_queue_Flush_critical( Thread_queue_Context *queue_context ) { - size_t flushed; - Chain_Control unblock; - Thread_Control *owner; - Chain_Node *node; - Chain_Node *tail; + size_t flushed; + size_t priority_updates; + Chain_Control unblock; + Chain_Node *node; + Chain_Node *tail; flushed = 0; + priority_updates = 0; _Chain_Initialize_empty( &unblock ); - owner = queue->owner; while ( true ) { Thread_queue_Heads *heads; @@ -99,8 +118,7 @@ size_t _Thread_queue_Flush_critical( /* * We do not have enough space in the queue context to collect all priority - * updates, so clear it each time. We unconditionally do the priority - * update for the owner later if it exists. + * updates, so clear it each time and accumulate the priority updates. */ _Thread_queue_Context_clear_priority_updates( queue_context ); @@ -120,6 +138,8 @@ size_t _Thread_queue_Flush_critical( ); } + priority_updates += + _Thread_queue_Context_get_priority_updates( queue_context ); ++flushed; } @@ -145,9 +165,12 @@ size_t _Thread_queue_Flush_critical( node = next; } while ( node != tail ); - if ( owner != NULL ) { + if ( priority_updates != 0 ) { + Thread_Control *owner; ISR_lock_Context lock_context; + owner = queue->owner; + _Assert( owner != NULL ); _Thread_State_acquire( owner, &lock_context ); _Scheduler_Update_priority( owner ); _Thread_State_release( owner, &lock_context ); |