source: rtems/c/src/exec/rtems/headers/sem.h @ 60b791ad

4.104.114.84.95
Last change on this file since 60b791ad was 60b791ad, checked in by Joel Sherrill <joel.sherrill@…>, on 02/17/98 at 23:46:28

updated copyright to 1998

  • Property mode set to 100644
File size: 5.9 KB
Line 
1/*  semaphore.h
2 *
3 *  This include file contains all the constants and structures associated
4 *  with the Semaphore Manager.  This manager utilizes standard Dijkstra
5 *  counting semaphores to provide synchronization and mutual exclusion
6 *  capabilities.
7 *
8 *  Directives provided are:
9 *
10 *     + create a semaphore
11 *     + get an ID of a semaphore
12 *     + delete a semaphore
13 *     + acquire a semaphore
14 *     + release a semaphore
15 *
16 *  COPYRIGHT (c) 1989-1998.
17 *  On-Line Applications Research Corporation (OAR).
18 *  Copyright assigned to U.S. Government, 1994.
19 *
20 *  The license and distribution terms for this file may be
21 *  found in the file LICENSE in this distribution or at
22 *  http://www.OARcorp.com/rtems/license.html.
23 *
24 *  $Id$
25 */
26
27#ifndef __RTEMS_SEMAPHORE_h
28#define __RTEMS_SEMAPHORE_h
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include <rtems/rtems/types.h>
35#include <rtems/rtems/support.h>
36#include <rtems/rtems/tasks.h>
37#include <rtems/rtems/attr.h>
38#include <rtems/score/coremutex.h>
39#include <rtems/score/object.h>
40#include <rtems/score/coresem.h>
41#include <rtems/score/threadq.h>
42
43/*
44 *  The following defines the control block used to manage each semaphore.
45 */
46
47typedef struct {
48  Objects_Control          Object;
49  rtems_attribute          attribute_set;
50  union {
51    CORE_mutex_Control     mutex;
52    CORE_semaphore_Control semaphore;
53  } Core_control;
54}   Semaphore_Control;
55
56/*
57 *  The following defines the information control block used to manage
58 *  this class of objects.
59 */
60
61RTEMS_EXTERN Objects_Information  _Semaphore_Information;
62
63/*
64 *  _Semaphore_Manager_initialization
65 *
66 *  DESCRIPTION:
67 *
68 *  This routine performs the initialization necessary for this manager.
69 */
70
71void _Semaphore_Manager_initialization(
72  unsigned32 maximum_semaphores
73);
74
75/*
76 *  rtems_semaphore_create
77 *
78 *  DESCRIPTION:
79 *
80 *  This routine implements the rtems_semaphore_create directive.  The
81 *  semaphore will have the name name.  The starting count for
82 *  the semaphore is count.  The attribute_set determines if
83 *  the semaphore is global or local and the thread queue
84 *  discipline.  It returns the id of the created semaphore in ID.
85 */
86
87rtems_status_code rtems_semaphore_create(
88  rtems_name           name,
89  unsigned32           count,
90  rtems_attribute      attribute_set,
91  rtems_task_priority  priority_ceiling,
92  rtems_id            *id
93);
94
95/*
96 *  rtems_semaphore_ident
97 *
98 *  DESCRIPTION:
99 *
100 *  This routine implements the rtems_semaphore_ident directive.
101 *  This directive returns the semaphore ID associated with name.
102 *  If more than one semaphore is named name, then the semaphore
103 *  to which the ID belongs is arbitrary.  node indicates the
104 *  extent of the search for the ID of the semaphore named name.
105 *  The search can be limited to a particular node or allowed to
106 *  encompass all nodes.
107 */
108
109rtems_status_code rtems_semaphore_ident(
110  rtems_name    name,
111  unsigned32    node,
112  rtems_id     *id
113);
114
115/*
116 *  rtems_semaphore_delete
117 *
118 *  DESCRIPTION:
119 *
120 *  This routine implements the rtems_semaphore_delete directive.  The
121 *  semaphore indicated by ID is deleted.
122 */
123
124rtems_status_code rtems_semaphore_delete(
125  rtems_id   id
126);
127
128/*
129 *  rtems_semaphore_obtain
130 *
131 *  DESCRIPTION:
132 *
133 *  This routine implements the rtems_semaphore_obtain directive.  It
134 *  attempts to obtain a unit from the semaphore associated with ID.
135 *  If a unit can be allocated, the calling task will return immediately.
136 *  If no unit is available, then the task may return immediately or
137 *  block waiting for a unit with an optional timeout of timeout
138 *  clock ticks.  Whether the task blocks or returns immediately
139 *  is based on the RTEMS_NO_WAIT option in the option_set.
140 */
141
142rtems_status_code rtems_semaphore_obtain(
143  rtems_id       id,
144  unsigned32     option_set,
145  rtems_interval timeout
146);
147
148/*
149 *  rtems_semaphore_release
150 *
151 *  DESCRIPTION:
152 *
153 *  This routine implements the rtems_semaphore_release directive.  It
154 *  frees a unit to the semaphore associated with ID.  If a task was
155 *  blocked waiting for a unit from this semaphore, then that task will
156 *  be readied and the unit given to that task.  Otherwise, the unit
157 *  will be returned to the semaphore.
158 */
159
160rtems_status_code rtems_semaphore_release(
161  rtems_id   id
162);
163
164/*
165 *  _Semaphore_Seize
166 *
167 *  DESCRIPTION:
168 *
169 *  This routine attempts to receive a unit from the_semaphore.
170 *  If a unit is available or if the RTEMS_NO_WAIT option is enabled in
171 *  option_set, then the routine returns.  Otherwise, the calling task
172 *  is blocked until a unit becomes available.
173 */
174
175boolean _Semaphore_Seize(
176  Semaphore_Control *the_semaphore,
177  unsigned32         option_set
178);
179
180/*
181 *  _Semaphore_Translate_core_mutex_return_code
182 *
183 *  DESCRIPTION:
184 *
185 *  This function returns a RTEMS status code based on the mutex
186 *  status code specified.
187 */
188 
189rtems_status_code _Semaphore_Translate_core_mutex_return_code (
190  unsigned32 the_mutex_status
191);
192
193/*
194 *  _Semaphore_Translate_core_semaphore_return_code
195 *
196 *  DESCRIPTION:
197 *
198 *  This function returns a RTEMS status code based on the semaphore
199 *  status code specified.
200 */
201 
202rtems_status_code _Semaphore_Translate_core_semaphore_return_code (
203  unsigned32 the_mutex_status
204);
205 
206/*PAGE
207 *
208 *  _Semaphore_Core_mutex_mp_support
209 *
210 *  DESCRIPTION:
211 *
212 *  This function processes the global actions necessary for remote
213 *  accesses to a global semaphore based on a core mutex.  This function
214 *  is called by the core.
215 */
216
217void  _Semaphore_Core_mutex_mp_support (
218  Thread_Control *the_thread,
219  rtems_id        id
220);
221
222/*PAGE
223 *
224 *  _Semaphore_Core_mp_support
225 *
226 *  DESCRIPTION:
227 *
228 *  This function processes the global actions necessary for remote
229 *  accesses to a global semaphore based on a core semaphore.  This function
230 *  is called by the core.
231 */
232 
233void  _Semaphore_Core_semaphore_mp_support (
234  Thread_Control *the_thread,
235  rtems_id        id
236);
237
238#ifndef __RTEMS_APPLICATION__
239#include <rtems/rtems/sem.inl>
240#endif
241#include <rtems/rtems/semmp.h>
242
243#ifdef __cplusplus
244}
245#endif
246
247#endif
248/*  end of include file */
Note: See TracBrowser for help on using the repository browser.