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

Subversion Repositories openrisc_me

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  $Id: mutexlocksupp.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
 *  _POSIX_Mutex_Lock_support
22
 *
23
 *  A support routine which implements guts of the blocking, non-blocking, and
24
 *  timed wait version of mutex lock.
25
 */
26
 
27
int _POSIX_Mutex_Lock_support(
28
  pthread_mutex_t           *mutex,
29
  boolean                    blocking,
30
  Watchdog_Interval          timeout
31
)
32
{
33
  register POSIX_Mutex_Control *the_mutex;
34
  Objects_Locations             location;
35
 
36
  the_mutex = _POSIX_Mutex_Get( mutex, &location );
37
  switch ( location ) {
38
    case OBJECTS_REMOTE:
39
#if defined(RTEMS_MULTIPROCESSING)
40
      return _POSIX_Mutex_MP_Send_request_packet(
41
          POSIX_MUTEX_MP_OBTAIN_REQUEST,
42
          *mutex,
43
          0,   /* must define the option set */
44
          WATCHDOG_NO_TIMEOUT
45
      );
46
#endif
47
    case OBJECTS_ERROR:
48
      return EINVAL;
49
    case OBJECTS_LOCAL:
50
      _CORE_mutex_Seize(
51
        &the_mutex->Mutex,
52
        the_mutex->Object.id,
53
        blocking,
54
        timeout
55
      );
56
      _Thread_Enable_dispatch();
57
      return _POSIX_Mutex_From_core_mutex_status(
58
        (CORE_mutex_Status) _Thread_Executing->Wait.return_code
59
      );
60
  }
61
  return POSIX_BOTTOM_REACHED();
62
}

powered by: WebSVN 2.1.0

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