summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/mutexlocksupp.c
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/src/mutexlocksupp.c
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/src/mutexlocksupp.c')
-rw-r--r--cpukit/posix/src/mutexlocksupp.c59
1 files changed, 50 insertions, 9 deletions
diff --git a/cpukit/posix/src/mutexlocksupp.c b/cpukit/posix/src/mutexlocksupp.c
index 6ecf87cb46..2499ae1ace 100644
--- a/cpukit/posix/src/mutexlocksupp.c
+++ b/cpukit/posix/src/mutexlocksupp.c
@@ -21,16 +21,39 @@
#include <rtems/posix/muteximpl.h>
#include <rtems/posix/posixapi.h>
-THREAD_QUEUE_OBJECT_ASSERT( POSIX_Mutex_Control, Mutex.Wait_queue );
+THREAD_QUEUE_OBJECT_ASSERT(
+ POSIX_Mutex_Control,
+ Mutex.Recursive.Mutex.Wait_queue
+);
+
+static Status_Control _POSIX_Mutex_Lock_nested(
+ CORE_recursive_mutex_Control *the_recursive_mutex
+)
+{
+ POSIX_Mutex_Control *the_mutex;
+
+ the_mutex = RTEMS_CONTAINER_OF(
+ the_recursive_mutex,
+ POSIX_Mutex_Control,
+ Mutex.Recursive
+ );
+
+ if ( the_mutex->is_recursive ) {
+ return _CORE_recursive_mutex_Seize_nested( the_recursive_mutex );
+ } else {
+ return STATUS_NESTING_NOT_ALLOWED;
+ }
+}
int _POSIX_Mutex_Lock_support(
pthread_mutex_t *mutex,
- bool blocking,
+ bool wait,
Watchdog_Interval timeout
)
{
POSIX_Mutex_Control *the_mutex;
Thread_queue_Context queue_context;
+ Thread_Control *executing;
Status_Control status;
the_mutex = _POSIX_Mutex_Get( mutex, &queue_context );
@@ -39,12 +62,30 @@ int _POSIX_Mutex_Lock_support(
return EINVAL;
}
- status = _CORE_mutex_Seize(
- &the_mutex->Mutex,
- _Thread_Executing,
- blocking,
- timeout,
- &queue_context
- );
+ executing = _Thread_Executing;
+
+ switch ( the_mutex->protocol ) {
+ case POSIX_MUTEX_NO_PROTOCOL:
+ status = _CORE_recursive_mutex_Seize_no_protocol(
+ &the_mutex->Mutex.Recursive,
+ POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS,
+ executing,
+ wait,
+ timeout,
+ _POSIX_Mutex_Lock_nested,
+ &queue_context
+ );
+ break;
+ default:
+ status = _CORE_mutex_Seize(
+ &the_mutex->Mutex.Recursive.Mutex,
+ executing,
+ wait,
+ timeout,
+ &queue_context
+ );
+ break;
+ }
+
return _POSIX_Get_error( status );
}