source: rtems/cpukit/posix/src/mutexsetprioceiling.c @ 9f95a19

4.104.114.84.95
Last change on this file since 9f95a19 was 9f95a19, checked in by Joel Sherrill <joel.sherrill@…>, on 11/02/99 at 18:35:52

Split time.c into multiple files.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  $Id$
3 */
4
5#include <assert.h>
6#include <errno.h>
7#include <pthread.h>
8
9#include <rtems/system.h>
10#include <rtems/score/coremutex.h>
11#include <rtems/score/watchdog.h>
12#if defined(RTEMS_MULTIPROCESSING)
13#include <rtems/score/mpci.h>
14#endif
15#include <rtems/posix/mutex.h>
16#include <rtems/posix/priority.h>
17#include <rtems/posix/time.h>
18
19/*PAGE
20 *
21 *  13.6.2 Change the Priority Ceiling of a Mutex, P1003.1c/Draft 10, p. 131
22 */
23
24int pthread_mutex_setprioceiling(
25  pthread_mutex_t   *mutex,
26  int                prioceiling,
27  int               *old_ceiling
28)
29{
30  register POSIX_Mutex_Control *the_mutex;
31  Objects_Locations             location;
32  Priority_Control              the_priority;
33  int                           status;
34
35  if ( !old_ceiling )
36    return EINVAL;
37
38  if ( !_POSIX_Priority_Is_valid( prioceiling ) )
39    return EINVAL;
40
41  the_priority = _POSIX_Priority_To_core( prioceiling );
42
43  /*
44   *  Must acquire the mutex before we can change it's ceiling
45   */
46
47  status = pthread_mutex_lock( mutex );
48  if ( status )
49    return status;
50
51  the_mutex = _POSIX_Mutex_Get( mutex, &location );
52  switch ( location ) {
53    case OBJECTS_REMOTE:
54#if defined(RTEMS_MULTIPROCESSING)
55      /*  XXX It feels questionable to set the ceiling on a remote mutex. */
56      return EINVAL;
57#endif
58    case OBJECTS_ERROR:
59      return EINVAL;        /* impossible to get here */
60    case OBJECTS_LOCAL:
61      *old_ceiling = _POSIX_Priority_From_core(
62        the_mutex->Mutex.Attributes.priority_ceiling
63      );
64      the_mutex->Mutex.Attributes.priority_ceiling = the_priority;
65      _CORE_mutex_Surrender(
66        &the_mutex->Mutex,
67        the_mutex->Object.id,
68#if defined(RTEMS_MULTIPROCESSING)
69        POSIX_Threads_mutex_MP_support
70#else
71        NULL
72#endif
73      );
74      _Thread_Enable_dispatch();
75      return 0;
76  }
77  return POSIX_BOTTOM_REACHED();
78}
Note: See TracBrowser for help on using the repository browser.