summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-06-14 06:50:38 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-06-22 14:00:27 +0200
commitce6e9ec22f3a4ba976c9de2b7b0fbe646f1b36de (patch)
tree1927796575a82887ae53875d7ceb05599f8a0264 /cpukit/posix
parent655ce0fb00c75c523dd81466a2dcf611171e4650 (diff)
downloadrtems-ce6e9ec22f3a4ba976c9de2b7b0fbe646f1b36de.tar.bz2
posix: pthread_mutexattr_setprioceiling()
Accept all priority values in pthread_mutexattr_setprioceiling(). This is in line with POSIX and FreeBSD. The priority is validated in pthread_mutex_init(). Validate the priority only for priority ceiling mutexes.
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/src/mutexattrsetprioceiling.c9
-rw-r--r--cpukit/posix/src/mutexinit.c19
2 files changed, 11 insertions, 17 deletions
diff --git a/cpukit/posix/src/mutexattrsetprioceiling.c b/cpukit/posix/src/mutexattrsetprioceiling.c
index ba377a99cc..3411121ad1 100644
--- a/cpukit/posix/src/mutexattrsetprioceiling.c
+++ b/cpukit/posix/src/mutexattrsetprioceiling.c
@@ -21,12 +21,6 @@
#include <errno.h>
#include <pthread.h>
-#include <rtems/system.h>
-#include <rtems/score/coremuteximpl.h>
-#include <rtems/score/watchdog.h>
-#include <rtems/posix/muteximpl.h>
-#include <rtems/posix/priorityimpl.h>
-
/*
* 13.6.1 Mutex Initialization Scheduling Attributes, P1003.1c/Draft 10, p. 128
*/
@@ -39,9 +33,6 @@ int pthread_mutexattr_setprioceiling(
if ( !attr || !attr->is_initialized )
return EINVAL;
- if ( !_POSIX_Priority_Is_valid( prioceiling ) )
- return EINVAL;
-
attr->prio_ceiling = prioceiling;
return 0;
}
diff --git a/cpukit/posix/src/mutexinit.c b/cpukit/posix/src/mutexinit.c
index 73f0544965..3459df77dd 100644
--- a/cpukit/posix/src/mutexinit.c
+++ b/cpukit/posix/src/mutexinit.c
@@ -36,6 +36,7 @@ int pthread_mutex_init(
POSIX_Mutex_Control *the_mutex;
const pthread_mutexattr_t *the_attr;
POSIX_Mutex_Protocol protocol;
+ Priority_Control priority;
if ( attr ) the_attr = attr;
else the_attr = &_POSIX_Mutex_Default_attributes;
@@ -86,12 +87,6 @@ int pthread_mutex_init(
return EINVAL;
}
- /*
- * Validate the priority ceiling field -- should always be valid.
- */
- if ( !_POSIX_Priority_Is_valid( the_attr->prio_ceiling ) )
- return EINVAL;
-
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
/*
* Validate the mutex type and set appropriate SuperCore mutex
@@ -109,6 +104,14 @@ int pthread_mutex_init(
}
#endif
+ if ( protocol == POSIX_MUTEX_PRIORITY_CEILING ) {
+ if ( !_POSIX_Priority_Is_valid( the_attr->prio_ceiling ) ) {
+ return EINVAL;
+ }
+
+ priority = _POSIX_Priority_To_core( the_attr->prio_ceiling );
+ }
+
the_mutex = _POSIX_Mutex_Allocate();
if ( !the_mutex ) {
@@ -119,11 +122,11 @@ int pthread_mutex_init(
the_mutex->protocol = protocol;
the_mutex->is_recursive = ( the_attr->type == PTHREAD_MUTEX_RECURSIVE );
- switch ( the_mutex->protocol ) {
+ switch ( protocol ) {
case POSIX_MUTEX_PRIORITY_CEILING:
_CORE_ceiling_mutex_Initialize(
&the_mutex->Mutex,
- _POSIX_Priority_To_core( the_attr->prio_ceiling )
+ priority
);
break;
default: