source: rtems/cpukit/posix/src/mutexsetprioceiling.c @ 0e87deaa

4.104.114.95
Last change on this file since 0e87deaa was 0e87deaa, checked in by Joel Sherrill <joel.sherrill@…>, on 10/26/07 at 20:19:02

2007-10-26 Joel Sherrill <joel.sherrill@…>

  • itron/src/can_wup.c, itron/src/chg_pri.c, itron/src/del_mbf.c, itron/src/del_mbx.c, itron/src/del_sem.c, itron/src/del_tsk.c, itron/src/frsm_tsk.c, itron/src/ref_mbf.c, itron/src/ref_mbx.c, itron/src/ref_sem.c, itron/src/ref_tsk.c, itron/src/rel_wai.c, itron/src/rsm_tsk.c, itron/src/sig_sem.c, itron/src/snd_mbx.c, itron/src/sta_tsk.c, itron/src/sus_tsk.c, itron/src/ter_tsk.c, itron/src/trcv_mbf.c, itron/src/trcv_mbx.c, itron/src/tsnd_mbf.c, itron/src/twai_sem.c, posix/src/cancel.c, posix/src/conddestroy.c, posix/src/condinit.c, posix/src/condsignalsupp.c, posix/src/condwaitsupp.c, posix/src/keydelete.c, posix/src/keygetspecific.c, posix/src/keysetspecific.c, posix/src/mqueueclose.c, posix/src/mqueuegetattr.c, posix/src/mqueuenotify.c, posix/src/mqueuerecvsupp.c, posix/src/mqueuesendsupp.c, posix/src/mqueuesetattr.c, posix/src/mutexdestroy.c, posix/src/mutexgetprioceiling.c, posix/src/mutexinit.c, posix/src/mutexlocksupp.c, posix/src/mutexsetprioceiling.c, posix/src/mutexunlock.c, posix/src/pbarrierdestroy.c, posix/src/pbarrierwait.c, posix/src/prwlockdestroy.c, posix/src/prwlockrdlock.c, posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, posix/src/prwlocktryrdlock.c, posix/src/prwlocktrywrlock.c, posix/src/prwlockunlock.c, posix/src/prwlockwrlock.c, posix/src/pspindestroy.c, posix/src/pspinlock.c, posix/src/pspintrylock.c, posix/src/pspinunlock.c, posix/src/pthreaddetach.c, posix/src/pthreadequal.c, posix/src/pthreadgetschedparam.c, posix/src/pthreadjoin.c, posix/src/pthreadkill.c, posix/src/pthreadsetschedparam.c, posix/src/ptimer1.c, posix/src/semaphorewaitsupp.c, posix/src/semclose.c, posix/src/semdestroy.c, posix/src/semgetvalue.c, posix/src/sempost.c, posix/src/types.c, rtems/src/barrierdelete.c, rtems/src/barrierrelease.c, rtems/src/barrierwait.c, rtems/src/dpmemdelete.c, rtems/src/dpmemexternal2internal.c, rtems/src/dpmeminternal2external.c, rtems/src/eventsend.c, rtems/src/eventtimeout.c, rtems/src/msgqbroadcast.c, rtems/src/msgqdelete.c, rtems/src/msgqflush.c, rtems/src/msgqgetnumberpending.c, rtems/src/msgqreceive.c, rtems/src/msgqsend.c, rtems/src/msgqurgent.c, rtems/src/partdelete.c, rtems/src/partgetbuffer.c, rtems/src/partreturnbuffer.c, rtems/src/ratemoncancel.c, rtems/src/ratemondelete.c, rtems/src/ratemongetstatistics.c, rtems/src/ratemongetstatus.c, rtems/src/ratemonperiod.c, rtems/src/ratemonresetstatistics.c, rtems/src/ratemontimeout.c, rtems/src/regiondelete.c, rtems/src/regionextend.c, rtems/src/regiongetfreeinfo.c, rtems/src/regiongetinfo.c, rtems/src/regiongetsegment.c, rtems/src/regiongetsegmentsize.c, rtems/src/regionresizesegment.c, rtems/src/regionreturnsegment.c, rtems/src/semdelete.c, rtems/src/semflush.c, rtems/src/semobtain.c, rtems/src/semrelease.c, rtems/src/signalsend.c, rtems/src/taskdelete.c, rtems/src/taskgetnote.c, rtems/src/taskissuspended.c, rtems/src/taskrestart.c, rtems/src/taskresume.c, rtems/src/tasksetnote.c, rtems/src/tasksetpriority.c, rtems/src/taskstart.c, rtems/src/tasksuspend.c, rtems/src/taskvariableadd.c, rtems/src/taskvariabledelete.c, rtems/src/taskvariableget.c, rtems/src/timercancel.c, rtems/src/timerdelete.c, rtems/src/timerfireafter.c, rtems/src/timerfirewhen.c, rtems/src/timergetinfo.c, rtems/src/timerreset.c, rtems/src/timerserverfireafter.c, rtems/src/timerserverfirewhen.c, sapi/src/extensiondelete.c, score/include/rtems/score/object.h, score/src/corerwlocktimeout.c, score/src/mpci.c, score/src/objectgetnameasstring.c, score/src/threaddelayended.c, score/src/threadqtimeout.c: When multiprocessing is disabled, do not even allow the constant OBJECTS_REMOTE to appear in the source. Even at -O2, the presence of a case OBJECTS_REMOTE in each id->pointer _Objects_Get switch results in the generation of binary code which can NOT be reached.
  • Property mode set to 100644
File size: 1.8 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#if defined(RTEMS_MULTIPROCESSING)
16#include <rtems/score/mpci.h>
17#endif
18#include <rtems/posix/mutex.h>
19#include <rtems/posix/priority.h>
20#include <rtems/posix/time.h>
21
22/*PAGE
23 *
24 *  13.6.2 Change the Priority Ceiling of a Mutex, P1003.1c/Draft 10, p. 131
25 */
26
27int pthread_mutex_setprioceiling(
28  pthread_mutex_t   *mutex,
29  int                prioceiling,
30  int               *old_ceiling
31)
32{
33  register POSIX_Mutex_Control *the_mutex;
34  Objects_Locations             location;
35  Priority_Control              the_priority;
36  int                           status;
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   */
49
50  status = pthread_mutex_lock( mutex );
51  if ( status )
52    return status;
53
54  the_mutex = _POSIX_Mutex_Get( mutex, &location );
55  switch ( location ) {
56#if defined(RTEMS_MULTIPROCESSING)
57    case OBJECTS_REMOTE:
58      /*  XXX It feels questionable to set the ceiling on a remote mutex. */
59      return EINVAL;
60#endif
61    case OBJECTS_ERROR:
62      return EINVAL;        /* impossible to get here */
63    case OBJECTS_LOCAL:
64      *old_ceiling = _POSIX_Priority_From_core(
65        the_mutex->Mutex.Attributes.priority_ceiling
66      );
67      the_mutex->Mutex.Attributes.priority_ceiling = the_priority;
68      _CORE_mutex_Surrender(
69        &the_mutex->Mutex,
70        the_mutex->Object.id,
71#if defined(RTEMS_MULTIPROCESSING)
72        _POSIX_Threads_mutex_MP_support
73#else
74        NULL
75#endif
76      );
77      _Thread_Enable_dispatch();
78      return 0;
79  }
80  return POSIX_BOTTOM_REACHED();
81}
Note: See TracBrowser for help on using the repository browser.