source: rtems/cpukit/posix/src/mutexsetprioceiling.c @ 976162a6

4.104.114.9
Last change on this file since 976162a6 was 976162a6, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 3, 2007 at 10:23:13 PM

2007-12-03 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/malloc.c, libmisc/monitor/mon-command.c, posix/preinstall.am, posix/include/rtems/posix/cond.h, posix/include/rtems/posix/mqueue.h, posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/pthread.h, posix/include/rtems/posix/semaphore.h, posix/src/conddestroy.c, posix/src/mutexdestroy.c, posix/src/mutexinit.c, posix/src/mutexsetprioceiling.c, posix/src/mutexunlock.c, sapi/include/confdefs.h, sapi/include/rtems/config.h, sapi/include/rtems/init.h, sapi/include/rtems/sptables.h, sapi/src/exinit.c, score/include/rtems/system.h, score/include/rtems/score/mpci.h, score/src/mpci.c, score/src/thread.c, score/src/threadcreateidle.c, score/src/threadstackallocate.c, score/src/threadstackfree.c, score/src/wkspace.c: Moved most of the remaining CPU Table fields to the Configuration Table. This included pretasking_hook, predriver_hook, postdriver_hook, idle_task, do_zero_of_workspace, extra_mpci_receive_server_stack, stack_allocate_hook, and stack_free_hook. As a side-effect of this effort some multiprocessing code was made conditional and some style clean up occurred.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  $Id$
3 */
4
5#if HAVE_CONFIG_H
6#include "config.h"
7#endif
8
9#include <errno.h>
10#include <pthread.h>
11
12#include <rtems/system.h>
13#include <rtems/score/coremutex.h>
14#include <rtems/score/watchdog.h>
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
54    case OBJECTS_LOCAL:
55      *old_ceiling = _POSIX_Priority_From_core(
56        the_mutex->Mutex.Attributes.priority_ceiling
57      );
58      the_mutex->Mutex.Attributes.priority_ceiling = the_priority;
59      _CORE_mutex_Surrender(
60        &the_mutex->Mutex,
61        the_mutex->Object.id,
62        NULL
63      );
64      _Thread_Enable_dispatch();
65      return 0;
66
67#if defined(RTEMS_MULTIPROCESSING)
68    case OBJECTS_REMOTE:  /* impossible to get here */
69#endif
70    case OBJECTS_ERROR:
71      break;
72  }
73
74  return EINVAL;
75}
Note: See TracBrowser for help on using the repository browser.