1 | /* rtems/posix/semaphore.h |
---|
2 | * |
---|
3 | * This include file contains all the private support information for |
---|
4 | * POSIX Semaphores. |
---|
5 | * |
---|
6 | * COPYRIGHT (c) 1989-1998. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * Copyright assigned to U.S. Government, 1994. |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.OARcorp.com/rtems/license.html. |
---|
13 | * |
---|
14 | * $Id$ |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef __RTEMS_POSIX_SEMAPHORE_h |
---|
18 | #define __RTEMS_POSIX_SEMAPHORE_h |
---|
19 | |
---|
20 | #ifdef __cplusplus |
---|
21 | extern "C" { |
---|
22 | #endif |
---|
23 | |
---|
24 | #include <semaphore.h> |
---|
25 | #include <rtems/score/coresem.h> |
---|
26 | |
---|
27 | #define SEM_FAILED (sem_t *) -1 |
---|
28 | |
---|
29 | /* |
---|
30 | * Data Structure used to manage a POSIX semaphore |
---|
31 | */ |
---|
32 | |
---|
33 | typedef struct { |
---|
34 | Objects_Control Object; |
---|
35 | int process_shared; |
---|
36 | boolean named; |
---|
37 | boolean linked; |
---|
38 | unsigned32 open_count; |
---|
39 | CORE_semaphore_Control Semaphore; |
---|
40 | } POSIX_Semaphore_Control; |
---|
41 | |
---|
42 | /* |
---|
43 | * The following defines the information control block used to manage |
---|
44 | * this class of objects. |
---|
45 | */ |
---|
46 | |
---|
47 | POSIX_EXTERN Objects_Information _POSIX_Semaphore_Information; |
---|
48 | |
---|
49 | /* |
---|
50 | * _POSIX_Semaphore_Manager_initialization |
---|
51 | * |
---|
52 | * DESCRIPTION: |
---|
53 | * |
---|
54 | * This routine performs the initialization necessary for this manager. |
---|
55 | */ |
---|
56 | |
---|
57 | void _POSIX_Semaphore_Manager_initialization( |
---|
58 | unsigned32 maximum_semaphorees |
---|
59 | ); |
---|
60 | |
---|
61 | /* |
---|
62 | * _POSIX_Semaphore_Allocate |
---|
63 | * |
---|
64 | * DESCRIPTION: |
---|
65 | * |
---|
66 | * This function allocates a semaphore control block from |
---|
67 | * the inactive chain of free semaphore control blocks. |
---|
68 | */ |
---|
69 | |
---|
70 | RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Allocate( void ); |
---|
71 | |
---|
72 | /* |
---|
73 | * _POSIX_Semaphore_Free |
---|
74 | * |
---|
75 | * DESCRIPTION: |
---|
76 | * |
---|
77 | * This routine frees a semaphore control block to the |
---|
78 | * inactive chain of free semaphore control blocks. |
---|
79 | */ |
---|
80 | |
---|
81 | RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free ( |
---|
82 | POSIX_Semaphore_Control *the_semaphore |
---|
83 | ); |
---|
84 | |
---|
85 | /* |
---|
86 | * _POSIX_Semaphore_Get |
---|
87 | * |
---|
88 | * DESCRIPTION: |
---|
89 | * |
---|
90 | * This function maps semaphore IDs to semaphore control blocks. |
---|
91 | * If ID corresponds to a local semaphore, then it returns |
---|
92 | * the_semaphore control pointer which maps to ID and location |
---|
93 | * is set to OBJECTS_LOCAL. if the semaphore ID is global and |
---|
94 | * resides on a remote node, then location is set to OBJECTS_REMOTE, |
---|
95 | * and the_semaphore is undefined. Otherwise, location is set |
---|
96 | * to OBJECTS_ERROR and the_semaphore is undefined. |
---|
97 | */ |
---|
98 | |
---|
99 | RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get ( |
---|
100 | Objects_Id *id, |
---|
101 | Objects_Locations *location |
---|
102 | ); |
---|
103 | |
---|
104 | /* |
---|
105 | * _POSIX_Semaphore_Is_null |
---|
106 | * |
---|
107 | * DESCRIPTION: |
---|
108 | * |
---|
109 | * This function returns TRUE if the_semaphore is NULL and FALSE otherwise. |
---|
110 | */ |
---|
111 | |
---|
112 | RTEMS_INLINE_ROUTINE boolean _POSIX_Semaphore_Is_null ( |
---|
113 | POSIX_Semaphore_Control *the_semaphore |
---|
114 | ); |
---|
115 | |
---|
116 | /* |
---|
117 | * _POSIX_Semaphore_Create_support |
---|
118 | * |
---|
119 | * DESCRIPTION: |
---|
120 | * |
---|
121 | * This routine supports the sem_init and sem_open routines. |
---|
122 | */ |
---|
123 | |
---|
124 | int _POSIX_Semaphore_Create_support( |
---|
125 | const char *name, |
---|
126 | int pshared, |
---|
127 | unsigned int value, |
---|
128 | POSIX_Semaphore_Control **the_sem |
---|
129 | ); |
---|
130 | |
---|
131 | /* |
---|
132 | * _POSIX_Semaphore_Wait_support |
---|
133 | * |
---|
134 | * DESCRIPTION: |
---|
135 | * |
---|
136 | * This routine supports the sem_wait, sem_trywait, and sem_timedwait |
---|
137 | * services. |
---|
138 | */ |
---|
139 | |
---|
140 | int _POSIX_Semaphore_Wait_support( |
---|
141 | sem_t *sem, |
---|
142 | boolean blocking, |
---|
143 | Watchdog_Interval timeout |
---|
144 | ); |
---|
145 | |
---|
146 | /* |
---|
147 | * _POSIX_Semaphore_Name_to_id |
---|
148 | * |
---|
149 | * DESCRIPTION: |
---|
150 | * |
---|
151 | * This routine performs name to id translation. |
---|
152 | */ |
---|
153 | |
---|
154 | int _POSIX_Semaphore_Name_to_id( |
---|
155 | const char *name, |
---|
156 | Objects_Id *id |
---|
157 | ); |
---|
158 | |
---|
159 | #include <rtems/posix/semaphore.inl> |
---|
160 | #if defined(RTEMS_MULTIPROCESSING) |
---|
161 | #include <rtems/posix/semaphoremp.h> |
---|
162 | #endif |
---|
163 | |
---|
164 | #ifdef __cplusplus |
---|
165 | } |
---|
166 | #endif |
---|
167 | |
---|
168 | #endif |
---|
169 | /* end of include file */ |
---|
170 | |
---|