summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pbarrierinit.c
diff options
context:
space:
mode:
authorGlenn Humphrey <glenn.humphrey@oarcorp.com>2007-11-06 19:52:36 +0000
committerGlenn Humphrey <glenn.humphrey@oarcorp.com>2007-11-06 19:52:36 +0000
commit8a8f5b263ae4a42b85a2d0c4a598b9702e04a57e (patch)
tree8ee935170b0b7bb403d9be6082cdaff91adb9063 /cpukit/posix/src/pbarrierinit.c
parent2007-11-06 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-8a8f5b263ae4a42b85a2d0c4a598b9702e04a57e.tar.bz2
2007-11-06 Glenn Humphrey <glenn.humphrey@OARcorp.com>
Miscellaneous changes made after a review against the POSIX spec. * posix/src/pbarrierinit.c, posix/src/prwlockinit.c: If the caller passes a NULL in the attributes parameter, default attributes are used. * posix/src/prwlockdestroy.c: If there is at least one thread waiting, do not allow deletion. * posix/src/prwlockwrlock.c: Corrected parameter passed to the core operation used to obtain a RWLock for writing. * posix/src/pspinlocktranslatereturncode.c, score/include/rtems/score/corespinlock.h, score/src/corespinlockrelease.c: If the current thread is not the holder of the lock, do not allow an unlock and return EPERM. * score/src/corerwlockobtainwrite.c: Corrected to use the operation for queueing with a timeout handler.
Diffstat (limited to 'cpukit/posix/src/pbarrierinit.c')
-rw-r--r--cpukit/posix/src/pbarrierinit.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/cpukit/posix/src/pbarrierinit.c b/cpukit/posix/src/pbarrierinit.c
index 408964cfed..816e695504 100644
--- a/cpukit/posix/src/pbarrierinit.c
+++ b/cpukit/posix/src/pbarrierinit.c
@@ -43,23 +43,37 @@ int pthread_barrier_init(
unsigned int count
)
{
- POSIX_Barrier_Control *the_barrier;
- CORE_barrier_Attributes the_attributes;
-
-
+ POSIX_Barrier_Control *the_barrier;
+ CORE_barrier_Attributes the_attributes;
+ pthread_barrierattr_t my_attr;
+ const pthread_barrierattr_t *the_attr;
+
+ /*
+ * Error check parameters
+ */
if ( !barrier )
return EINVAL;
if ( count == 0 )
return EINVAL;
- if ( !attr )
- return EINVAL;
+ /*
+ * If the user passed in NULL, use the default attributes
+ */
+ if ( attr ) {
+ the_attr = attr;
+ } else {
+ (void) pthread_barrierattr_init( &my_attr );
+ the_attr = &my_attr;
+ }
- if ( !attr->is_initialized )
+ /*
+ * Now start error checking the attributes that we are going to use
+ */
+ if ( !the_attr->is_initialized )
return EINVAL;
- switch ( attr->process_shared ) {
+ switch ( the_attr->process_shared ) {
case PTHREAD_PROCESS_PRIVATE: /* only supported values */
break;
case PTHREAD_PROCESS_SHARED:
@@ -67,9 +81,15 @@ int pthread_barrier_init(
return EINVAL;
}
+ /*
+ * Convert from POSIX attributes to Core Barrier attributes
+ */
the_attributes.discipline = CORE_BARRIER_AUTOMATIC_RELEASE;
the_attributes.maximum_count = count;
+ /*
+ * Enter dispatching critical section to allocate and initialize barrier
+ */
_Thread_Disable_dispatch(); /* prevents deletion */
the_barrier = _POSIX_Barrier_Allocate();
@@ -87,8 +107,10 @@ int pthread_barrier_init(
0
);
+ /*
+ * Exit the critical section and return the user an operational barrier
+ */
*barrier = the_barrier->Object.id;
-
_Thread_Enable_dispatch();
return 0;
}