summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-27 15:41:41 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-30 16:16:23 +0200
commit33e250c9fa370f620ddbc5850342d5a90b123524 (patch)
treea2f4082a58231054f084e9a77aa0af4e3111662d /cpukit/posix/src
parentscore: Add CORE mutex variants (diff)
downloadrtems-33e250c9fa370f620ddbc5850342d5a90b123524.tar.bz2
score: Rework CORE priority ceiling mutex
Rework seize and surrender methods to use CORE_ceiling_mutex_Control. This eliminates CORE_mutex_Disciplines.
Diffstat (limited to 'cpukit/posix/src')
-rw-r--r--cpukit/posix/src/mutexgetprioceiling.c2
-rw-r--r--cpukit/posix/src/mutexinit.c16
-rw-r--r--cpukit/posix/src/mutexlocksupp.c11
-rw-r--r--cpukit/posix/src/mutexsetprioceiling.c5
-rw-r--r--cpukit/posix/src/mutexunlock.c8
5 files changed, 28 insertions, 14 deletions
diff --git a/cpukit/posix/src/mutexgetprioceiling.c b/cpukit/posix/src/mutexgetprioceiling.c
index 06eaf30764..2df4776048 100644
--- a/cpukit/posix/src/mutexgetprioceiling.c
+++ b/cpukit/posix/src/mutexgetprioceiling.c
@@ -46,7 +46,7 @@ int pthread_mutex_getprioceiling(
_POSIX_Mutex_Acquire_critical( the_mutex, &queue_context );
*prioceiling = _POSIX_Priority_From_core(
- the_mutex->Mutex.Recursive.Mutex.Attributes.priority_ceiling
+ the_mutex->Mutex.priority_ceiling
);
_POSIX_Mutex_Release( the_mutex, &queue_context );
diff --git a/cpukit/posix/src/mutexinit.c b/cpukit/posix/src/mutexinit.c
index f2912ead18..6c5705b20b 100644
--- a/cpukit/posix/src/mutexinit.c
+++ b/cpukit/posix/src/mutexinit.c
@@ -119,7 +119,12 @@ int pthread_mutex_init(
the_mutex->protocol = protocol;
the_mutex->is_recursive = ( the_attr->type == PTHREAD_MUTEX_RECURSIVE );
- if ( protocol == POSIX_MUTEX_NO_PROTOCOL ) {
+ if ( protocol == POSIX_MUTEX_PRIORITY_CEILING ) {
+ _CORE_ceiling_mutex_Initialize(
+ &the_mutex->Mutex,
+ _POSIX_Priority_To_core( the_attr->prio_ceiling )
+ );
+ } else if ( protocol == POSIX_MUTEX_NO_PROTOCOL ) {
_CORE_recursive_mutex_Initialize(
&the_mutex->Mutex.Recursive
);
@@ -132,15 +137,6 @@ int pthread_mutex_init(
the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_IS_ERROR;
}
- the_mutex_attr.priority_ceiling =
- _POSIX_Priority_To_core( the_attr->prio_ceiling );
-
- if ( protocol == POSIX_MUTEX_PRIORITY_CEILING ) {
- the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING;
- } else {
- the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT;
- }
-
/*
* Must be initialized to unlocked.
*/
diff --git a/cpukit/posix/src/mutexlocksupp.c b/cpukit/posix/src/mutexlocksupp.c
index 2499ae1ace..cccb2d31b3 100644
--- a/cpukit/posix/src/mutexlocksupp.c
+++ b/cpukit/posix/src/mutexlocksupp.c
@@ -65,6 +65,16 @@ int _POSIX_Mutex_Lock_support(
executing = _Thread_Executing;
switch ( the_mutex->protocol ) {
+ case POSIX_MUTEX_PRIORITY_CEILING:
+ status = _CORE_ceiling_mutex_Seize(
+ &the_mutex->Mutex,
+ executing,
+ wait,
+ timeout,
+ _POSIX_Mutex_Lock_nested,
+ &queue_context
+ );
+ break;
case POSIX_MUTEX_NO_PROTOCOL:
status = _CORE_recursive_mutex_Seize_no_protocol(
&the_mutex->Mutex.Recursive,
@@ -77,6 +87,7 @@ int _POSIX_Mutex_Lock_support(
);
break;
default:
+ _Assert( the_mutex->protocol == POSIX_MUTEX_PRIORITY_INHERIT );
status = _CORE_mutex_Seize(
&the_mutex->Mutex.Recursive.Mutex,
executing,
diff --git a/cpukit/posix/src/mutexsetprioceiling.c b/cpukit/posix/src/mutexsetprioceiling.c
index 5d11edf294..96e8dbfeba 100644
--- a/cpukit/posix/src/mutexsetprioceiling.c
+++ b/cpukit/posix/src/mutexsetprioceiling.c
@@ -57,10 +57,9 @@ int pthread_mutex_setprioceiling(
_Assert( the_mutex != NULL );
*old_ceiling = _POSIX_Priority_From_core(
- the_mutex->Mutex.Recursive.Mutex.Attributes.priority_ceiling
+ the_mutex->Mutex.priority_ceiling
);
- the_mutex->Mutex.Recursive.Mutex.Attributes.priority_ceiling =
- the_priority;
+ the_mutex->Mutex.priority_ceiling = the_priority;
error = pthread_mutex_unlock( mutex );
_Assert( error == 0 );
diff --git a/cpukit/posix/src/mutexunlock.c b/cpukit/posix/src/mutexunlock.c
index b0ca33d154..5404cef187 100644
--- a/cpukit/posix/src/mutexunlock.c
+++ b/cpukit/posix/src/mutexunlock.c
@@ -45,6 +45,13 @@ int pthread_mutex_unlock(
executing = _Thread_Executing;
switch ( the_mutex->protocol ) {
+ case POSIX_MUTEX_PRIORITY_CEILING:
+ status = _CORE_ceiling_mutex_Surrender(
+ &the_mutex->Mutex,
+ executing,
+ &queue_context
+ );
+ break;
case POSIX_MUTEX_NO_PROTOCOL:
status = _CORE_recursive_mutex_Surrender_no_protocol(
&the_mutex->Mutex.Recursive,
@@ -54,6 +61,7 @@ int pthread_mutex_unlock(
);
break;
default:
+ _Assert( the_mutex->protocol == POSIX_MUTEX_PRIORITY_INHERIT );
status = _CORE_mutex_Surrender(
&the_mutex->Mutex.Recursive.Mutex,
&queue_context