5
Last change
on this file since 0e16fa45 was
de59c065,
checked in by Sebastian Huber <sebastian.huber@…>, on 09/27/17 at 13:08:33
|
posix: Implement self-contained POSIX mutex
POSIX mutexes are now available in all configurations and no longer
depend on --enable-posix.
Update #2514.
Update #3112.
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Initializing and Destroying a Mutex |
---|
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 | |
---|
23 | /* |
---|
24 | * 11.3.2 Initializing and Destroying a Mutex, P1003.1c/Draft 10, p. 87 |
---|
25 | */ |
---|
26 | |
---|
27 | int pthread_mutex_destroy( |
---|
28 | pthread_mutex_t *mutex |
---|
29 | ) |
---|
30 | { |
---|
31 | POSIX_Mutex_Control *the_mutex; |
---|
32 | unsigned long flags; |
---|
33 | Thread_queue_Context queue_context; |
---|
34 | int eno; |
---|
35 | |
---|
36 | the_mutex = _POSIX_Mutex_Get( mutex ); |
---|
37 | POSIX_MUTEX_VALIDATE_OBJECT( the_mutex, flags ); |
---|
38 | |
---|
39 | _POSIX_Mutex_Acquire( the_mutex, &queue_context ); |
---|
40 | |
---|
41 | if ( _POSIX_Mutex_Get_owner( the_mutex ) == NULL ) { |
---|
42 | the_mutex->flags = ~the_mutex->flags; |
---|
43 | eno = 0; |
---|
44 | } else { |
---|
45 | eno = EBUSY; |
---|
46 | } |
---|
47 | |
---|
48 | _POSIX_Mutex_Release( the_mutex, &queue_context ); |
---|
49 | return eno; |
---|
50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.