1 | /** |
---|
2 | * @file rtems/posix/mutex.h |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * This include file contains all the private support information for |
---|
7 | * POSIX mutex's. |
---|
8 | * |
---|
9 | * COPYRIGHT (c) 1989-1999. |
---|
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.com/license/LICENSE. |
---|
15 | * |
---|
16 | * $Id$ |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef __RTEMS_POSIX_MUTEX_h |
---|
20 | #define __RTEMS_POSIX_MUTEX_h |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif |
---|
25 | |
---|
26 | #include <rtems/score/coremutex.h> |
---|
27 | #include <pthread.h> |
---|
28 | |
---|
29 | /* |
---|
30 | * Data Structure used to manage a POSIX mutex |
---|
31 | */ |
---|
32 | |
---|
33 | typedef struct { |
---|
34 | Objects_Control Object; |
---|
35 | int process_shared; |
---|
36 | CORE_mutex_Control Mutex; |
---|
37 | } POSIX_Mutex_Control; |
---|
38 | |
---|
39 | /* |
---|
40 | * The following defines the information control block used to manage |
---|
41 | * this class of objects. |
---|
42 | */ |
---|
43 | |
---|
44 | POSIX_EXTERN Objects_Information _POSIX_Mutex_Information; |
---|
45 | |
---|
46 | /* |
---|
47 | * The default mutex attributes structure. |
---|
48 | */ |
---|
49 | |
---|
50 | extern const pthread_mutexattr_t _POSIX_Mutex_Default_attributes; |
---|
51 | |
---|
52 | /* |
---|
53 | * _POSIX_Mutex_Manager_initialization |
---|
54 | * |
---|
55 | * DESCRIPTION: |
---|
56 | * |
---|
57 | * This routine performs the initialization necessary for this manager. |
---|
58 | */ |
---|
59 | |
---|
60 | void _POSIX_Mutex_Manager_initialization( |
---|
61 | uint32_t maximum_mutexes |
---|
62 | ); |
---|
63 | |
---|
64 | /* |
---|
65 | * _POSIX_Mutex_Allocate |
---|
66 | * |
---|
67 | * DESCRIPTION: |
---|
68 | * |
---|
69 | * This function allocates a mutexes control block from |
---|
70 | * the inactive chain of free mutexes control blocks. |
---|
71 | */ |
---|
72 | |
---|
73 | RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Allocate( void ); |
---|
74 | |
---|
75 | /* |
---|
76 | * _POSIX_Mutex_Free |
---|
77 | * |
---|
78 | * DESCRIPTION: |
---|
79 | * |
---|
80 | * This routine frees a mutexes control block to the |
---|
81 | * inactive chain of free mutexes control blocks. |
---|
82 | */ |
---|
83 | |
---|
84 | RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Free ( |
---|
85 | POSIX_Mutex_Control *the_mutex |
---|
86 | ); |
---|
87 | |
---|
88 | #if 0 |
---|
89 | /* |
---|
90 | * _POSIX_Mutex_Get |
---|
91 | * |
---|
92 | * DESCRIPTION: |
---|
93 | * |
---|
94 | * This function maps mutexes IDs to mutexes control blocks. |
---|
95 | * If ID corresponds to a local mutexes, then it returns |
---|
96 | * the_mutex control pointer which maps to ID and location |
---|
97 | * is set to OBJECTS_LOCAL. if the mutexes ID is global and |
---|
98 | * resides on a remote node, then location is set to OBJECTS_REMOTE, |
---|
99 | * and the_mutex is undefined. Otherwise, location is set |
---|
100 | * to OBJECTS_ERROR and the_mutex is undefined. |
---|
101 | */ |
---|
102 | |
---|
103 | RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get ( |
---|
104 | Objects_Id *id, |
---|
105 | Objects_Locations *location |
---|
106 | ); |
---|
107 | |
---|
108 | /* |
---|
109 | * _POSIX_Mutex_Is_null |
---|
110 | * |
---|
111 | * DESCRIPTION: |
---|
112 | * |
---|
113 | * This function returns TRUE if the_mutex is NULL and FALSE otherwise. |
---|
114 | */ |
---|
115 | |
---|
116 | RTEMS_INLINE_ROUTINE boolean _POSIX_Mutex_Is_null ( |
---|
117 | POSIX_Mutex_Control *the_mutex |
---|
118 | ); |
---|
119 | #endif |
---|
120 | |
---|
121 | /* |
---|
122 | * _POSIX_Mutex_Lock_support |
---|
123 | * |
---|
124 | * DESCRIPTION: |
---|
125 | * |
---|
126 | * A support routine which implements guts of the blocking, non-blocking, and |
---|
127 | * timed wait version of mutex lock. |
---|
128 | */ |
---|
129 | |
---|
130 | int _POSIX_Mutex_Lock_support( |
---|
131 | pthread_mutex_t *mutex, |
---|
132 | boolean blocking, |
---|
133 | Watchdog_Interval timeout |
---|
134 | ); |
---|
135 | |
---|
136 | /* |
---|
137 | * _POSIX_Mutex_From_core_mutex_status |
---|
138 | * |
---|
139 | * DESCRIPTION: |
---|
140 | * |
---|
141 | * A support routine which converts core mutex status codes into the |
---|
142 | * appropriate POSIX status values. |
---|
143 | */ |
---|
144 | |
---|
145 | int _POSIX_Mutex_From_core_mutex_status( |
---|
146 | CORE_mutex_Status status |
---|
147 | ); |
---|
148 | |
---|
149 | |
---|
150 | #include <rtems/posix/mutex.inl> |
---|
151 | #if defined(RTEMS_MULTIPROCESSING) |
---|
152 | #include <rtems/posix/mutexmp.h> |
---|
153 | #endif |
---|
154 | |
---|
155 | #ifdef __cplusplus |
---|
156 | } |
---|
157 | #endif |
---|
158 | |
---|
159 | #endif |
---|
160 | /* end of include file */ |
---|