diff options
Diffstat (limited to '')
-rw-r--r-- | cpukit/rtems/src/semsetpriority.c | 81 |
1 files changed, 45 insertions, 36 deletions
diff --git a/cpukit/rtems/src/semsetpriority.c b/cpukit/rtems/src/semsetpriority.c index adb0320210..30e64770ea 100644 --- a/cpukit/rtems/src/semsetpriority.c +++ b/cpukit/rtems/src/semsetpriority.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * Copyright (c) 2014 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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 @@ -29,20 +42,6 @@ #include <rtems/rtems/tasksimpl.h> #include <rtems/score/schedulerimpl.h> -static rtems_status_code _Semaphore_Is_scheduler_valid( - const CORE_ceiling_mutex_Control *the_mutex, - const Scheduler_Control *scheduler -) -{ -#if defined(RTEMS_SMP) - if ( scheduler != _CORE_ceiling_mutex_Get_scheduler( the_mutex ) ) { - return RTEMS_NOT_DEFINED; - } -#endif - - return RTEMS_SUCCESSFUL; -} - static rtems_status_code _Semaphore_Set_priority( Semaphore_Control *the_semaphore, const Scheduler_Control *scheduler, @@ -51,7 +50,6 @@ static rtems_status_code _Semaphore_Set_priority( Thread_queue_Context *queue_context ) { - rtems_status_code sc; bool valid; Priority_Control core_priority; Priority_Control old_priority; @@ -73,20 +71,29 @@ static rtems_status_code _Semaphore_Set_priority( switch ( variant ) { case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING: - sc = _Semaphore_Is_scheduler_valid( - &the_semaphore->Core_control.Mutex, - scheduler - ); +#if defined(RTEMS_SMP) + if ( + scheduler != _CORE_ceiling_mutex_Get_scheduler( + &the_semaphore->Core_control.Mutex + ) + ) { + _Thread_queue_Release( + &the_semaphore->Core_control.Wait_queue, + queue_context + ); + + return RTEMS_NOT_DEFINED; + } +#endif old_priority = _CORE_ceiling_mutex_Get_priority( &the_semaphore->Core_control.Mutex ); - if ( sc == RTEMS_SUCCESSFUL && new_priority != RTEMS_CURRENT_PRIORITY ) { + if ( new_priority != RTEMS_CURRENT_PRIORITY ) { _CORE_ceiling_mutex_Set_priority( &the_semaphore->Core_control.Mutex, - core_priority, - queue_context + core_priority ); } @@ -106,7 +113,6 @@ static rtems_status_code _Semaphore_Set_priority( ); } - sc = RTEMS_SUCCESSFUL; break; #endif default: @@ -116,9 +122,12 @@ static rtems_status_code _Semaphore_Set_priority( || variant == SEMAPHORE_VARIANT_SIMPLE_BINARY || variant == SEMAPHORE_VARIANT_COUNTING ); - old_priority = 0; - sc = RTEMS_NOT_DEFINED; - break; + _Thread_queue_Release( + &the_semaphore->Core_control.Wait_queue, + queue_context + ); + + return RTEMS_NOT_DEFINED; } cpu_self = _Thread_queue_Dispatch_disable( queue_context ); @@ -130,7 +139,7 @@ static rtems_status_code _Semaphore_Set_priority( _Thread_Dispatch_enable( cpu_self ); *old_priority_p = _RTEMS_Priority_From_core( scheduler, old_priority ); - return sc; + return RTEMS_SUCCESSFUL; } rtems_status_code rtems_semaphore_set_priority( |