source: rtems/cpukit/posix/src/mutexsetprioceiling.c @ 8f6b7b51

4.104.115
Last change on this file since 8f6b7b51 was 33a5381, checked in by Joel Sherrill <joel.sherrill@…>, on 07/07/09 at 21:04:57

2009-07-07 Joel Sherrill <joel.sherrill@…>

  • ChangeLog?, posix/src/mutexsetprioceiling.c: Remove warning.
  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <errno.h>
17#include <pthread.h>
18
19#include <rtems/system.h>
20#include <rtems/score/coremutex.h>
21#include <rtems/score/watchdog.h>
22#include <rtems/posix/mutex.h>
23#include <rtems/posix/priority.h>
24#include <rtems/posix/time.h>
25
26/*PAGE
27 *
28 *  13.6.2 Change the Priority Ceiling of a Mutex, P1003.1c/Draft 10, p. 131
29 */
30
31int pthread_mutex_setprioceiling(
32  pthread_mutex_t   *mutex,
33  int                prioceiling,
34  int               *old_ceiling
35)
36{
37  register POSIX_Mutex_Control *the_mutex;
38  Objects_Locations             location;
39  Priority_Control              the_priority;
40
41  if ( !old_ceiling )
42    return EINVAL;
43
44  if ( !_POSIX_Priority_Is_valid( prioceiling ) )
45    return EINVAL;
46
47  the_priority = _POSIX_Priority_To_core( prioceiling );
48
49  /*
50   *  Must acquire the mutex before we can change it's ceiling.
51   *  POSIX says block until we acquire it.
52   */
53  (void) pthread_mutex_lock( mutex );
54
55  /*
56   *  Do not worry about the return code from this.  The Get operation
57   *  will also fail if it is a bad id or was deleted between the two
58   *  operations.
59   *
60   *  NOTE: This makes it easier to get 100% binary coverage since the
61   *        bad Id case is handled by the switch.
62   */
63  the_mutex = _POSIX_Mutex_Get( mutex, &location );
64  switch ( location ) {
65
66    case OBJECTS_LOCAL:
67      *old_ceiling = _POSIX_Priority_From_core(
68        the_mutex->Mutex.Attributes.priority_ceiling
69      );
70      the_mutex->Mutex.Attributes.priority_ceiling = the_priority;
71      /*
72       *  We are required to unlock the mutex before we return.
73       */
74      _CORE_mutex_Surrender(
75        &the_mutex->Mutex,
76        the_mutex->Object.id,
77        NULL
78      );
79      _Thread_Enable_dispatch();
80
81      return 0;
82
83#if defined(RTEMS_MULTIPROCESSING)
84    case OBJECTS_REMOTE:  /* impossible to get here */
85#endif
86    case OBJECTS_ERROR:
87      break;
88  }
89
90  return EINVAL;
91}
Note: See TracBrowser for help on using the repository browser.