source: rtems/cpukit/posix/src/mutexlocksupp.c @ 188c82b

4.104.114.84.95
Last change on this file since 188c82b was 1b7e8c51, checked in by Joel Sherrill <joel.sherrill@…>, on 07/06/00 at 19:34:49

Switched to using _POSIX_Mutex_Get_interrupt_disable to improve performance.

  • Property mode set to 100644
File size: 1.5 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 *  _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
27int _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  ISR_Level                     level;
36 
37  the_mutex = _POSIX_Mutex_Get_interrupt_disable( mutex, &location, &level );
38  switch ( location ) {
39    case OBJECTS_REMOTE:
40#if defined(RTEMS_MULTIPROCESSING)
41      return _POSIX_Mutex_MP_Send_request_packet(
42          POSIX_MUTEX_MP_OBTAIN_REQUEST,
43          *mutex,
44          0,   /* must define the option set */
45          WATCHDOG_NO_TIMEOUT
46      );
47#endif
48    case OBJECTS_ERROR:
49      return EINVAL;
50    case OBJECTS_LOCAL:
51      _CORE_mutex_Seize(
52        &the_mutex->Mutex,
53        the_mutex->Object.id,
54        blocking,
55        timeout,
56        level
57      );
58      return _POSIX_Mutex_From_core_mutex_status(
59        (CORE_mutex_Status) _Thread_Executing->Wait.return_code
60      );
61  }
62  return POSIX_BOTTOM_REACHED();
63}
Note: See TracBrowser for help on using the repository browser.