summaryrefslogblamecommitdiffstats
path: root/cpukit/posix/src/mutexgetprioceiling.c
blob: e66e98366efbf135d76c79a266e0ea328f20561e (plain) (tree)
1
2
3
4
5
6
7
8



                                                           
                    

   
  




                                                           
                                         

   



                   
                                  
                                     
 
  
                                                                            
   



                                 

 

                                    
 
                              
                  
   
 
                                                                         
 

                            
   
 








                                                                   
 
/**
 * @file
 *
 * @brief Returns the Current Priority Ceiling of the Mutex
 * @ingroup POSIXAPI
 */

/*
 *  COPYRIGHT (c) 1989-2007.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <rtems/posix/muteximpl.h>
#include <rtems/posix/priorityimpl.h>

/*
 *  13.6.2 Change the Priority Ceiling of a Mutex, P1003.1c/Draft 10, p. 131
 */

int pthread_mutex_getprioceiling(
  pthread_mutex_t   *mutex,
  int               *prioceiling
)
{
  POSIX_Mutex_Control *the_mutex;
  ISR_lock_Context     lock_context;

  if ( prioceiling == NULL ) {
    return EINVAL;
  }

  the_mutex = _POSIX_Mutex_Get_interrupt_disable( mutex, &lock_context );

  if ( the_mutex == NULL ) {
    return EINVAL;
  }

  _CORE_mutex_Acquire_critical( &the_mutex->Mutex, &lock_context );

  *prioceiling = _POSIX_Priority_From_core(
    the_mutex->Mutex.Attributes.priority_ceiling
  );

  _CORE_mutex_Release( &the_mutex->Mutex, &lock_context );

  return 0;
}