source: rtems/cpukit/posix/src/mutexgetprioceiling.c @ 0e16fa45

5
Last change on this file since 0e16fa45 was 77fbbd6, checked in by Sebastian Huber <sebastian.huber@…>, on 07/03/18 at 09:50:53

posix: Check for new <pthread.h> prototypes

Update #3342.
Update #3343.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief Returns the Current Priority Ceiling of the Mutex
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/posix/muteximpl.h>
22#include <rtems/posix/priorityimpl.h>
23
24/*
25 *  13.6.2 Change the Priority Ceiling of a Mutex, P1003.1c/Draft 10, p. 131
26 */
27
28int pthread_mutex_getprioceiling(
29#ifdef HAVE_PTHREAD_MUTEX_GETCEILING_CONST
30  const pthread_mutex_t *mutex,
31#else
32  pthread_mutex_t       *mutex,
33#endif
34  int                   *prioceiling
35)
36{
37  POSIX_Mutex_Control  *the_mutex;
38  unsigned long         flags;
39  Thread_queue_Context  queue_context;
40
41  if ( prioceiling == NULL ) {
42    return EINVAL;
43  }
44
45  the_mutex = _POSIX_Mutex_Get( RTEMS_DECONST( pthread_mutex_t *, mutex ) );
46  POSIX_MUTEX_VALIDATE_OBJECT( the_mutex, flags );
47
48  _POSIX_Mutex_Acquire( the_mutex, &queue_context );
49
50  if ( _POSIX_Mutex_Get_protocol( flags ) == POSIX_MUTEX_PRIORITY_CEILING ) {
51    *prioceiling = _POSIX_Priority_From_core(
52      _POSIX_Mutex_Get_scheduler( the_mutex ),
53      _POSIX_Mutex_Get_priority( the_mutex )
54    );
55  } else {
56    *prioceiling = 0;
57  }
58
59  _POSIX_Mutex_Release( the_mutex, &queue_context );
60  return 0;
61}
Note: See TracBrowser for help on using the repository browser.