source: rtems/cpukit/posix/src/mutexget.c @ 48b04fc3

5
Last change on this file since 48b04fc3 was 48b04fc3, checked in by Sebastian Huber <sebastian.huber@…>, on 04/19/16 at 04:28:03

posix: Avoid Giant lock for mutexes

Delete _POSIX_Mutex_Get(). Use _POSIX_Mutex_Get_interrupt_disable()
instead.

Update #2555.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Convert POSIX Mutex ID to local object pointer
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/posix/muteximpl.h>
22#include <rtems/score/apimutex.h>
23
24static bool _POSIX_Mutex_Check_id_and_auto_init( pthread_mutex_t *mutex )
25{
26  if ( mutex == NULL ) {
27    return false;
28  }
29
30  if ( *mutex == PTHREAD_MUTEX_INITIALIZER ) {
31    int eno;
32
33    _Once_Lock();
34
35    if ( *mutex == PTHREAD_MUTEX_INITIALIZER ) {
36      eno = pthread_mutex_init( mutex, NULL );
37    } else {
38      eno = 0;
39    }
40
41    _Once_Unlock();
42
43    if ( eno != 0 ) {
44      return false;
45    }
46  }
47
48  return true;
49}
50
51POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable(
52  pthread_mutex_t  *mutex,
53  ISR_lock_Context *lock_context
54)
55{
56  Objects_Locations location;
57
58  if ( !_POSIX_Mutex_Check_id_and_auto_init( mutex ) ) {
59    return NULL;
60  }
61
62  return (POSIX_Mutex_Control *) _Objects_Get_isr_disable(
63    &_POSIX_Mutex_Information,
64    (Objects_Id) *mutex,
65    &location,
66    lock_context
67  );
68}
Note: See TracBrowser for help on using the repository browser.