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