summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/include
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-27 08:02:03 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-30 16:16:23 +0200
commit5a598ac99b0de720a04afc5e2ac6764117589b90 (patch)
tree811d57df33c0f4fcc1cce61095cb5c0a33eadd7c /cpukit/posix/include
parentposix: Delete POSIX_Mutex_Protocol::process_shared (diff)
downloadrtems-5a598ac99b0de720a04afc5e2ac6764117589b90.tar.bz2
score: Add CORE mutex variants
Add CORE_recursive_mutex_Control and CORE_ceiling_mutex_Control to avoid the run-time evaluation of attributes to figure out how a particular mutex methods should behave. Start with the no protocol variants. This eliminates the CORE_MUTEX_DISCIPLINES_FIFO and CORE_MUTEX_DISCIPLINES_PRIORITY disciplines.
Diffstat (limited to 'cpukit/posix/include')
-rw-r--r--cpukit/posix/include/rtems/posix/mutex.h33
-rw-r--r--cpukit/posix/include/rtems/posix/muteximpl.h35
2 files changed, 62 insertions, 6 deletions
diff --git a/cpukit/posix/include/rtems/posix/mutex.h b/cpukit/posix/include/rtems/posix/mutex.h
index e1dfa34e8c..97ab138652 100644
--- a/cpukit/posix/include/rtems/posix/mutex.h
+++ b/cpukit/posix/include/rtems/posix/mutex.h
@@ -35,14 +35,35 @@ extern "C" {
*/
/**@{**/
-/*
- * Data Structure used to manage a POSIX mutex
+/**
+ * @brief The POSIX mutex control.
*/
-
typedef struct {
- Objects_Control Object;
- CORE_mutex_Control Mutex;
-} POSIX_Mutex_Control;
+ /**
+ * @brief The object control.
+ */
+ Objects_Control Object;
+
+ /**
+ * The most general mutex variant supported by a POSIX mutex.
+ *
+ * The priority inheritance or no protocol variants will use only parts of
+ * this structure.
+ */
+ CORE_ceiling_mutex_Control Mutex;
+
+ /**
+ * @brief The protocol variant.
+ *
+ * @see POSIX_Mutex_Protocol.
+ */
+ unsigned int protocol : 2;
+
+ /**
+ * @brief Indicates if this is a non-recursive or recursive mutex.
+ */
+ unsigned int is_recursive : 1;
+} POSIX_Mutex_Control;
/** @} */
diff --git a/cpukit/posix/include/rtems/posix/muteximpl.h b/cpukit/posix/include/rtems/posix/muteximpl.h
index 30cc19da7e..4957e207fb 100644
--- a/cpukit/posix/include/rtems/posix/muteximpl.h
+++ b/cpukit/posix/include/rtems/posix/muteximpl.h
@@ -28,6 +28,19 @@
extern "C" {
#endif
+#define POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
+
+/**
+ * @brief Supported POSIX mutex protocols.
+ *
+ * Must be in synchronization with POSIX_Mutex_Control::protocol.
+ */
+typedef enum {
+ POSIX_MUTEX_NO_PROTOCOL,
+ POSIX_MUTEX_PRIORITY_INHERIT,
+ POSIX_MUTEX_PRIORITY_CEILING
+} POSIX_Mutex_Protocol;
+
/**
* The following defines the information control block used to manage
* this class of objects.
@@ -39,6 +52,28 @@ extern Objects_Information _POSIX_Mutex_Information;
*/
extern pthread_mutexattr_t _POSIX_Mutex_Default_attributes;
+RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Acquire_critical(
+ POSIX_Mutex_Control *the_mutex,
+ Thread_queue_Context *queue_context
+)
+{
+ _CORE_mutex_Acquire_critical(
+ &the_mutex->Mutex.Recursive.Mutex,
+ queue_context
+ );
+}
+
+RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Release(
+ POSIX_Mutex_Control *the_mutex,
+ Thread_queue_Context *queue_context
+)
+{
+ _CORE_mutex_Release(
+ &the_mutex->Mutex.Recursive.Mutex,
+ queue_context
+ );
+}
+
/**
* @brief POSIX Mutex Allocate
*