OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [mutexsetprioceiling.c] - Blame information for rev 532

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  $Id: mutexsetprioceiling.c,v 1.2 2001-09-27 11:59:17 chris Exp $
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
 
24
int 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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.