diff options
Diffstat (limited to 'cpukit/score/src/threadqenqueue.c')
-rw-r--r-- | cpukit/score/src/threadqenqueue.c | 96 |
1 files changed, 34 insertions, 62 deletions
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c index 5fc357ec82..038c483f65 100644 --- a/cpukit/score/src/threadqenqueue.c +++ b/cpukit/score/src/threadqenqueue.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,8 +9,8 @@ * _Thread_queue_Deadlock_fatal(), _Thread_queue_Deadlock_status(), * _Thread_queue_Do_dequeue(), _Thread_queue_Enqueue(), * _Thread_queue_Enqueue_do_nothing_extra(), _Thread_queue_Enqueue_sticky(), - * _Thread_queue_Extract(), _Thread_queue_Extract_locked(), - * _Thread_queue_Path_acquire(), _Thread_queue_Path_release(), + * _Thread_queue_Extract_locked(), _Thread_queue_Path_acquire(), + * _Thread_queue_Path_release(), * _Thread_queue_Resume(),_Thread_queue_Surrender(), * _Thread_queue_Surrender_no_priority(), _Thread_queue_Surrender_sticky(). */ @@ -17,11 +19,28 @@ * COPYRIGHT (c) 1989-2014. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2015, 2016 embedded brains GmbH. + * Copyright (C) 2015, 2016 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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 @@ -41,9 +60,6 @@ #define THREAD_QUEUE_BLOCKED \ (THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_BLOCKED) -#define THREAD_QUEUE_READY_AGAIN \ - (THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_READY_AGAIN) - #if defined(RTEMS_SMP) /* * A global registry of active thread queue links is used to provide deadlock @@ -384,6 +400,7 @@ void _Thread_queue_Deadlock_status( Thread_Control *the_thread ) void _Thread_queue_Deadlock_fatal( Thread_Control *the_thread ) { + (void) the_thread; _Internal_error( INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK ); } @@ -518,7 +535,7 @@ Status_Control _Thread_queue_Enqueue_sticky( ); _Thread_Priority_update( queue_context ); - _Thread_Priority_and_sticky_update( the_thread, 1 ); + _Thread_Priority_update_and_make_sticky( the_thread ); _Thread_Dispatch_enable( cpu_self ); while ( @@ -534,7 +551,7 @@ Status_Control _Thread_queue_Enqueue_sticky( #endif #if defined(RTEMS_MULTIPROCESSING) -static bool _Thread_queue_MP_set_callout( +bool _Thread_queue_MP_set_callout( Thread_Control *the_thread, const Thread_queue_Context *queue_context ) @@ -560,7 +577,7 @@ static void _Thread_queue_Force_ready_again( Thread_Control *the_thread ) * We must set the wait flags under protection of the current thread lock, * otherwise a _Thread_Timeout() running on another processor may interfere. */ - _Thread_Wait_flags_set( the_thread, THREAD_QUEUE_READY_AGAIN ); + _Thread_Wait_flags_set( the_thread, THREAD_WAIT_STATE_READY ); _Thread_Wait_restore_default( the_thread ); } @@ -576,13 +593,13 @@ static bool _Thread_queue_Make_ready_again( Thread_Control *the_thread ) success = _Thread_Wait_flags_try_change_release( the_thread, THREAD_QUEUE_INTEND_TO_BLOCK, - THREAD_QUEUE_READY_AGAIN + THREAD_WAIT_STATE_READY ); if ( success ) { unblock = false; } else { _Assert( _Thread_Wait_flags_get( the_thread ) == THREAD_QUEUE_BLOCKED ); - _Thread_Wait_flags_set( the_thread, THREAD_QUEUE_READY_AGAIN ); + _Thread_Wait_flags_set( the_thread, THREAD_WAIT_STATE_READY ); unblock = true; } @@ -671,37 +688,6 @@ void _Thread_queue_Resume( } } -void _Thread_queue_Extract( Thread_Control *the_thread ) -{ - Thread_queue_Context queue_context; - Thread_queue_Queue *queue; - - _Thread_queue_Context_initialize( &queue_context ); - _Thread_queue_Context_clear_priority_updates( &queue_context ); - _Thread_Wait_acquire( the_thread, &queue_context ); - - queue = the_thread->Wait.queue; - - if ( queue != NULL ) { - _Thread_Wait_remove_request( the_thread, &queue_context.Lock_context ); - _Thread_queue_Context_set_MP_callout( - &queue_context, - _Thread_queue_MP_callout_do_nothing - ); -#if defined(RTEMS_MULTIPROCESSING) - _Thread_queue_MP_set_callout( the_thread, &queue_context ); -#endif - ( *the_thread->Wait.operations->extract )( - queue, - the_thread, - &queue_context - ); - _Thread_queue_Resume( queue, the_thread, &queue_context ); - } else { - _Thread_Wait_release( the_thread, &queue_context ); - } -} - void _Thread_queue_Surrender( Thread_queue_Queue *queue, Thread_queue_Heads *heads, @@ -758,8 +744,6 @@ void _Thread_queue_Surrender_no_priority( ) { Thread_Control *the_thread; - bool unblock; - Per_CPU_Control *cpu_self; _Assert( heads != NULL ); _Assert( queue->owner == NULL ); @@ -770,19 +754,7 @@ void _Thread_queue_Surrender_no_priority( _Thread_queue_MP_set_callout( the_thread, queue_context ); #endif - unblock = _Thread_queue_Make_ready_again( the_thread ); - - cpu_self = _Thread_queue_Dispatch_disable( queue_context ); - _Thread_queue_Queue_release( - queue, - &queue_context->Lock_context.Lock_context - ); - - if ( unblock ) { - _Thread_Remove_timer_and_unblock( the_thread, queue ); - } - - _Thread_Dispatch_enable( cpu_self ); + _Thread_queue_Resume( queue, the_thread, queue_context ); } Status_Control _Thread_queue_Surrender_priority_ceiling( @@ -899,8 +871,8 @@ void _Thread_queue_Surrender_sticky( queue, &queue_context->Lock_context.Lock_context ); - _Thread_Priority_and_sticky_update( previous_owner, -1 ); - _Thread_Priority_and_sticky_update( new_owner, 0 ); + _Thread_Priority_update_and_clean_sticky( previous_owner ); + _Thread_Priority_update_ignore_sticky( new_owner ); _Thread_Dispatch_enable( cpu_self ); } #endif |