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