summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/mutexinit.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-06 14:46:36 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-06 14:46:36 +0000
commit8cdf733f5003255ae7914f0a3b01f744f4add517 (patch)
tree5e21140343adc5ae9c3424765c6d3659f6ffb6d1 /cpukit/posix/src/mutexinit.c
parent2009-07-06 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-8cdf733f5003255ae7914f0a3b01f744f4add517.tar.bz2
2009-07-06 Joel Sherrill <joel.sherrill@oarcorp.com>
* posix/Makefile.am, posix/src/mutex.c, posix/src/mutexinit.c: Add initial support for the pthread mutex type attribute added by UNIX98. It can be normal, recursive, errorcheck or default. * posix/src/mutexattrgettype.c, posix/src/mutexattrsettype.c: New files.
Diffstat (limited to 'cpukit/posix/src/mutexinit.c')
-rw-r--r--cpukit/posix/src/mutexinit.c65
1 files changed, 43 insertions, 22 deletions
diff --git a/cpukit/posix/src/mutexinit.c b/cpukit/posix/src/mutexinit.c
index 353049a879..ca8a93011c 100644
--- a/cpukit/posix/src/mutexinit.c
+++ b/cpukit/posix/src/mutexinit.c
@@ -40,10 +40,6 @@ int pthread_mutex_init(
CORE_mutex_Attributes *the_mutex_attr;
const pthread_mutexattr_t *the_attr;
CORE_mutex_Disciplines the_discipline;
-#if 0
- register POSIX_Mutex_Control *mutex_in_use;
- Objects_Locations location;
-#endif
if ( attr ) the_attr = attr;
else the_attr = &_POSIX_Mutex_Default_attributes;
@@ -70,27 +66,32 @@ int pthread_mutex_init(
* RTEMS port of omniORB2 when this code was enabled.
*
* Joel Sherrill <joel@OARcorp.com> 14 May 1999
+ * NOTE: Be careful to avoid infinite recursion on call to this
+ * routine in _POSIX_Mutex_Get.
*/
-#if 0
- /* avoid infinite recursion on call to this routine in _POSIX_Mutex_Get */
-
- if ( *mutex != PTHREAD_MUTEX_INITIALIZER ) {
-
- /* EBUSY if *mutex is a valid id */
-
- mutex_in_use = _POSIX_Mutex_Get( mutex, &location );
- switch ( location ) {
- case OBJECTS_LOCAL:
- _Thread_Enable_dispatch();
- return EBUSY;
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
-#endif
- case OBJECTS_ERROR:
- break;
+ #if 0
+ {
+ POSIX_Mutex_Control *mutex_in_use;
+ Objects_Locations location;
+
+ if ( *mutex != PTHREAD_MUTEX_INITIALIZER ) {
+
+ /* EBUSY if *mutex is a valid id */
+
+ mutex_in_use = _POSIX_Mutex_Get( mutex, &location );
+ switch ( location ) {
+ case OBJECTS_LOCAL:
+ _Thread_Enable_dispatch();
+ return EBUSY;
+ #if defined(RTEMS_MULTIPROCESSING)
+ case OBJECTS_REMOTE:
+ #endif
+ case OBJECTS_ERROR:
+ break;
+ }
}
}
-#endif
+ #endif
if ( !the_attr->is_initialized )
return EINVAL;
@@ -121,9 +122,29 @@ 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
+ * attributes.
+ */
+ switch ( the_attr->type ) {
+ case PTHREAD_MUTEX_NORMAL:
+ case PTHREAD_MUTEX_RECURSIVE:
+ case PTHREAD_MUTEX_ERRORCHECK:
+ case PTHREAD_MUTEX_DEFAULT:
+ break;
+
+ default:
+ return EINVAL;
+ }
+#endif
+
/*
* Enter a dispatching critical section and begin to do the real work.
*/