summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/posix/muteximpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/include/rtems/posix/muteximpl.h')
-rw-r--r--cpukit/include/rtems/posix/muteximpl.h114
1 files changed, 47 insertions, 67 deletions
diff --git a/cpukit/include/rtems/posix/muteximpl.h b/cpukit/include/rtems/posix/muteximpl.h
index 435b43634d..8dffea80a5 100644
--- a/cpukit/include/rtems/posix/muteximpl.h
+++ b/cpukit/include/rtems/posix/muteximpl.h
@@ -1,18 +1,37 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/**
* @file
*
* @brief Private Inlined Routines for POSIX Mutex's.
- *
- * This include file contains the static inline implementation of the private
+ *
+ * This include file contains the static inline implementation of the private
* inlined routines for POSIX mutex's.
*/
/* COPYRIGHT (c) 1989-2013.
* 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.
*/
#ifndef _RTEMS_POSIX_MUTEXIMPL_H
@@ -68,7 +87,7 @@ typedef enum {
*/
extern const pthread_mutexattr_t _POSIX_Mutex_Default_attributes;
-RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Mutex_Acquire(
+static inline Thread_Control *_POSIX_Mutex_Acquire(
POSIX_Mutex_Control *the_mutex,
Thread_queue_Context *queue_context
)
@@ -89,7 +108,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Mutex_Acquire(
return executing;
}
-RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Release(
+static inline void _POSIX_Mutex_Release(
POSIX_Mutex_Control *the_mutex,
Thread_queue_Context *queue_context
)
@@ -100,28 +119,28 @@ RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Release(
);
}
-RTEMS_INLINE_ROUTINE POSIX_Mutex_Protocol _POSIX_Mutex_Get_protocol(
+static inline POSIX_Mutex_Protocol _POSIX_Mutex_Get_protocol(
unsigned long flags
)
{
- return flags & POSIX_MUTEX_PROTOCOL_MASK;
+ return (POSIX_Mutex_Protocol) (flags & POSIX_MUTEX_PROTOCOL_MASK);
}
-RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_recursive(
+static inline bool _POSIX_Mutex_Is_recursive(
unsigned long flags
)
{
return ( flags & POSIX_MUTEX_RECURSIVE ) != 0;
}
-RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Mutex_Get_owner(
+static inline Thread_Control *_POSIX_Mutex_Get_owner(
const POSIX_Mutex_Control *the_mutex
)
{
return the_mutex->Recursive.Mutex.Queue.Queue.owner;
}
-RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_locked(
+static inline bool _POSIX_Mutex_Is_locked(
const POSIX_Mutex_Control *the_mutex
)
{
@@ -136,7 +155,7 @@ Status_Control _POSIX_Mutex_Seize_slow(
Thread_queue_Context *queue_context
);
-RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_owner(
+static inline void _POSIX_Mutex_Set_owner(
POSIX_Mutex_Control *the_mutex,
Thread_Control *owner
)
@@ -144,7 +163,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_owner(
the_mutex->Recursive.Mutex.Queue.Queue.owner = owner;
}
-RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_owner(
+static inline bool _POSIX_Mutex_Is_owner(
const POSIX_Mutex_Control *the_mutex,
const Thread_Control *the_thread
)
@@ -166,7 +185,7 @@ static Status_Control _POSIX_Mutex_Lock_nested(
}
}
-RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Seize(
+static inline Status_Control _POSIX_Mutex_Seize(
POSIX_Mutex_Control *the_mutex,
unsigned long flags,
const Thread_queue_Operations *operations,
@@ -203,7 +222,7 @@ RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Seize(
);
}
-RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Surrender(
+static inline Status_Control _POSIX_Mutex_Surrender(
POSIX_Mutex_Control *the_mutex,
const Thread_queue_Operations *operations,
Thread_Control *executing,
@@ -246,7 +265,7 @@ RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Surrender(
return STATUS_SUCCESSFUL;
}
-RTEMS_INLINE_ROUTINE const Scheduler_Control *_POSIX_Mutex_Get_scheduler(
+static inline const Scheduler_Control *_POSIX_Mutex_Get_scheduler(
const POSIX_Mutex_Control *the_mutex
)
{
@@ -257,7 +276,7 @@ RTEMS_INLINE_ROUTINE const Scheduler_Control *_POSIX_Mutex_Get_scheduler(
#endif
}
-RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_priority(
+static inline void _POSIX_Mutex_Set_priority(
POSIX_Mutex_Control *the_mutex,
Priority_Control priority_ceiling,
Thread_queue_Context *queue_context
@@ -273,7 +292,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_priority(
owner,
&the_mutex->Priority_ceiling,
priority_ceiling,
- false,
+ PRIORITY_GROUP_LAST,
queue_context
);
_Thread_Wait_release( owner, queue_context );
@@ -282,14 +301,14 @@ RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_priority(
}
}
-RTEMS_INLINE_ROUTINE Priority_Control _POSIX_Mutex_Get_priority(
+static inline Priority_Control _POSIX_Mutex_Get_priority(
const POSIX_Mutex_Control *the_mutex
)
{
return the_mutex->Priority_ceiling.priority;
}
-RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_set_owner(
+static inline Status_Control _POSIX_Mutex_Ceiling_set_owner(
POSIX_Mutex_Control *the_mutex,
Thread_Control *owner,
Thread_queue_Context *queue_context
@@ -328,7 +347,7 @@ RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_set_owner(
return STATUS_SUCCESSFUL;
}
-RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_seize(
+static inline Status_Control _POSIX_Mutex_Ceiling_seize(
POSIX_Mutex_Control *the_mutex,
unsigned long flags,
Thread_Control *executing,
@@ -376,16 +395,13 @@ RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_seize(
);
}
-RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_surrender(
+static inline Status_Control _POSIX_Mutex_Ceiling_surrender(
POSIX_Mutex_Control *the_mutex,
Thread_Control *executing,
Thread_queue_Context *queue_context
)
{
- unsigned int nest_level;
- ISR_lock_Context lock_context;
- Per_CPU_Control *cpu_self;
- Thread_queue_Heads *heads;
+ unsigned int nest_level;
if ( !_POSIX_Mutex_Is_owner( the_mutex, executing ) ) {
_POSIX_Mutex_Release( the_mutex, queue_context );
@@ -400,48 +416,13 @@ RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_surrender(
return STATUS_SUCCESSFUL;
}
- _Thread_Resource_count_decrement( executing );
-
- _Thread_queue_Context_clear_priority_updates( queue_context );
- _Thread_Wait_acquire_default_critical( executing, &lock_context );
- _Thread_Priority_remove(
+ return _Thread_queue_Surrender_priority_ceiling(
+ &the_mutex->Recursive.Mutex.Queue.Queue,
executing,
&the_mutex->Priority_ceiling,
- queue_context
+ queue_context,
+ POSIX_MUTEX_PRIORITY_CEILING_TQ_OPERATIONS
);
- _Thread_Wait_release_default_critical( executing, &lock_context );
-
- cpu_self = _Thread_queue_Dispatch_disable( queue_context );
-
- heads = the_mutex->Recursive.Mutex.Queue.Queue.heads;
-
- if ( heads != NULL ) {
- const Thread_queue_Operations *operations;
- Thread_Control *new_owner;
-
- operations = POSIX_MUTEX_PRIORITY_CEILING_TQ_OPERATIONS;
- new_owner = ( *operations->first )( heads );
- _POSIX_Mutex_Set_owner( the_mutex, new_owner );
- _Thread_Resource_count_increment( new_owner );
- _Thread_Priority_add(
- new_owner,
- &the_mutex->Priority_ceiling,
- queue_context
- );
- _Thread_queue_Extract_critical(
- &the_mutex->Recursive.Mutex.Queue.Queue,
- operations,
- new_owner,
- queue_context
- );
- } else {
- _POSIX_Mutex_Set_owner( the_mutex, NULL );
- _POSIX_Mutex_Release( the_mutex, queue_context );
- }
-
- _Thread_Priority_update( queue_context );
- _Thread_Dispatch_enable( cpu_self );
- return STATUS_SUCCESSFUL;
}
#define POSIX_MUTEX_ABSTIME_TRY_LOCK ((uintptr_t) 1)
@@ -484,4 +465,3 @@ bool _POSIX_Mutex_Auto_initialization( POSIX_Mutex_Control *the_mutex );
#endif
/* end of include file */
-