source: rtems/cpukit/posix/src/mutexsetprioceiling.c @ 33e250c9

5
Last change on this file since 33e250c9 was 33e250c9, checked in by Sebastian Huber <sebastian.huber@…>, on 05/27/16 at 13:41:41

score: Rework CORE priority ceiling mutex

Rework seize and surrender methods to use CORE_ceiling_mutex_Control.
This eliminates CORE_mutex_Disciplines.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief Changes the Priority Ceiling of a Mutex and Releases it
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2009.
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_setprioceiling(
29  pthread_mutex_t   *mutex,
30  int                prioceiling,
31  int               *old_ceiling
32)
33{
34  register POSIX_Mutex_Control *the_mutex;
35  Priority_Control              the_priority;
36  int                           error;
37
38  if ( !old_ceiling )
39    return EINVAL;
40
41  if ( !_POSIX_Priority_Is_valid( prioceiling ) )
42    return EINVAL;
43
44  the_priority = _POSIX_Priority_To_core( prioceiling );
45
46  /*
47   *  Must acquire the mutex before we can change it's ceiling.
48   *  POSIX says block until we acquire it.
49   */
50  error = pthread_mutex_lock( mutex );
51  if ( error != 0 ) {
52    _Assert( error == EINVAL );
53    return EINVAL;
54  }
55
56  the_mutex = _POSIX_Mutex_Get_no_protection( mutex );
57  _Assert( the_mutex != NULL );
58
59  *old_ceiling = _POSIX_Priority_From_core(
60    the_mutex->Mutex.priority_ceiling
61  );
62  the_mutex->Mutex.priority_ceiling = the_priority;
63
64  error = pthread_mutex_unlock( mutex );
65  _Assert( error == 0 );
66  (void) error;
67  return 0;
68}
Note: See TracBrowser for help on using the repository browser.