[rtems commit] posix: Avoid use of internal mutex methods

Sebastian Huber sebh at rtems.org
Mon May 30 14:17:58 UTC 2016


Module:    rtems
Branch:    master
Commit:    dbd65507a2fa452a1df3718d3b467dc8a6171358
Changeset: http://git.rtems.org/rtems/commit/?id=dbd65507a2fa452a1df3718d3b467dc8a6171358

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri May 27 11:10:42 2016 +0200

posix: Avoid use of internal mutex methods

Avoid use of internal mutex methods for pthread_mutex_setprioceiling().

---

 cpukit/posix/src/mutexsetprioceiling.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/cpukit/posix/src/mutexsetprioceiling.c b/cpukit/posix/src/mutexsetprioceiling.c
index 09554f8..20f14dc 100644
--- a/cpukit/posix/src/mutexsetprioceiling.c
+++ b/cpukit/posix/src/mutexsetprioceiling.c
@@ -33,7 +33,7 @@ int pthread_mutex_setprioceiling(
 {
   register POSIX_Mutex_Control *the_mutex;
   Priority_Control              the_priority;
-  Thread_queue_Context          queue_context;
+  int                           error;
 
   if ( !old_ceiling )
     return EINVAL;
@@ -47,33 +47,22 @@ int pthread_mutex_setprioceiling(
    *  Must acquire the mutex before we can change it's ceiling.
    *  POSIX says block until we acquire it.
    */
-  (void) pthread_mutex_lock( mutex );
-
-  /*
-   *  Do not worry about the return code from this.  The Get operation
-   *  will also fail if it is a bad id or was deleted between the two
-   *  operations.
-   *
-   *  NOTE: This makes it easier to get 100% binary coverage since the
-   *        bad Id case is handled by the switch.
-   */
-  the_mutex = _POSIX_Mutex_Get( mutex, &queue_context );
-
-  if ( the_mutex == NULL ) {
+  error = pthread_mutex_lock( mutex );
+  if ( error != 0 ) {
+    _Assert( error == EINVAL );
     return EINVAL;
   }
 
+  the_mutex = _POSIX_Mutex_Get_no_protection( mutex );
+  _Assert( the_mutex != NULL );
+
   *old_ceiling = _POSIX_Priority_From_core(
     the_mutex->Mutex.Attributes.priority_ceiling
   );
   the_mutex->Mutex.Attributes.priority_ceiling = the_priority;
 
-  /*
-   *  We are required to unlock the mutex before we return.
-   */
-  _CORE_mutex_Surrender(
-    &the_mutex->Mutex,
-    &queue_context
-  );
+  error = pthread_mutex_unlock( mutex );
+  _Assert( error == 0 );
+  (void) error;
   return 0;
 }




More information about the vc mailing list