OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [rtems/] [include/] [rtems/] [rtems/] [sem.h] - Blame information for rev 594

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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-1999.
17
 *  On-Line Applications Research Corporation (OAR).
18
 *
19
 *  The license and distribution terms for this file may be
20
 *  found in the file LICENSE in this distribution or at
21
 *  http://www.OARcorp.com/rtems/license.html.
22
 *
23
 *  $Id: sem.h,v 1.2 2001-09-27 11:59:18 chris Exp $
24
 */
25
 
26
#ifndef __RTEMS_SEMAPHORE_h
27
#define __RTEMS_SEMAPHORE_h
28
 
29
#ifdef __cplusplus
30
extern "C" {
31
#endif
32
 
33
#include <rtems/rtems/types.h>
34
#include <rtems/rtems/support.h>
35
#include <rtems/rtems/tasks.h>
36
#include <rtems/rtems/attr.h>
37
#include <rtems/score/coremutex.h>
38
#include <rtems/score/object.h>
39
#include <rtems/score/coresem.h>
40
#include <rtems/score/threadq.h>
41
 
42
/*
43
 *  The following defines the control block used to manage each semaphore.
44
 */
45
 
46
typedef struct {
47
  Objects_Control          Object;
48
  rtems_attribute          attribute_set;
49
  union {
50
    CORE_mutex_Control     mutex;
51
    CORE_semaphore_Control semaphore;
52
  } Core_control;
53
}   Semaphore_Control;
54
 
55
/*
56
 *  The following defines the information control block used to manage
57
 *  this class of objects.
58
 */
59
 
60
RTEMS_EXTERN Objects_Information  _Semaphore_Information;
61
 
62
/*
63
 *  _Semaphore_Manager_initialization
64
 *
65
 *  DESCRIPTION:
66
 *
67
 *  This routine performs the initialization necessary for this manager.
68
 */
69
 
70
void _Semaphore_Manager_initialization(
71
  unsigned32 maximum_semaphores
72
);
73
 
74
/*
75
 *  rtems_semaphore_create
76
 *
77
 *  DESCRIPTION:
78
 *
79
 *  This routine implements the rtems_semaphore_create directive.  The
80
 *  semaphore will have the name name.  The starting count for
81
 *  the semaphore is count.  The attribute_set determines if
82
 *  the semaphore is global or local and the thread queue
83
 *  discipline.  It returns the id of the created semaphore in ID.
84
 */
85
 
86
rtems_status_code rtems_semaphore_create(
87
  rtems_name           name,
88
  unsigned32           count,
89
  rtems_attribute      attribute_set,
90
  rtems_task_priority  priority_ceiling,
91
  rtems_id            *id
92
);
93
 
94
/*
95
 *  rtems_semaphore_ident
96
 *
97
 *  DESCRIPTION:
98
 *
99
 *  This routine implements the rtems_semaphore_ident directive.
100
 *  This directive returns the semaphore ID associated with name.
101
 *  If more than one semaphore is named name, then the semaphore
102
 *  to which the ID belongs is arbitrary.  node indicates the
103
 *  extent of the search for the ID of the semaphore named name.
104
 *  The search can be limited to a particular node or allowed to
105
 *  encompass all nodes.
106
 */
107
 
108
rtems_status_code rtems_semaphore_ident(
109
  rtems_name    name,
110
  unsigned32    node,
111
  rtems_id     *id
112
);
113
 
114
/*
115
 *  rtems_semaphore_delete
116
 *
117
 *  DESCRIPTION:
118
 *
119
 *  This routine implements the rtems_semaphore_delete directive.  The
120
 *  semaphore indicated by ID is deleted.
121
 */
122
 
123
rtems_status_code rtems_semaphore_delete(
124
  rtems_id   id
125
);
126
 
127
/*
128
 *  rtems_semaphore_obtain
129
 *
130
 *  DESCRIPTION:
131
 *
132
 *  This routine implements the rtems_semaphore_obtain directive.  It
133
 *  attempts to obtain a unit from the semaphore associated with ID.
134
 *  If a unit can be allocated, the calling task will return immediately.
135
 *  If no unit is available, then the task may return immediately or
136
 *  block waiting for a unit with an optional timeout of timeout
137
 *  clock ticks.  Whether the task blocks or returns immediately
138
 *  is based on the RTEMS_NO_WAIT option in the option_set.
139
 */
140
 
141
rtems_status_code rtems_semaphore_obtain(
142
  rtems_id       id,
143
  unsigned32     option_set,
144
  rtems_interval timeout
145
);
146
 
147
/*
148
 *  rtems_semaphore_release
149
 *
150
 *  DESCRIPTION:
151
 *
152
 *  This routine implements the rtems_semaphore_release directive.  It
153
 *  frees a unit to the semaphore associated with ID.  If a task was
154
 *  blocked waiting for a unit from this semaphore, then that task will
155
 *  be readied and the unit given to that task.  Otherwise, the unit
156
 *  will be returned to the semaphore.
157
 */
158
 
159
rtems_status_code rtems_semaphore_release(
160
  rtems_id   id
161
);
162
 
163
/*
164
 *  rtems_semaphore_flush
165
 *
166
 *  This directive allows a thread to flush the threads
167
 *  pending on the semaphore.
168
 */
169
 
170
rtems_status_code rtems_semaphore_flush(
171
  Objects_Id      id
172
);
173
 
174
/*
175
 *  _Semaphore_Seize
176
 *
177
 *  DESCRIPTION:
178
 *
179
 *  This routine attempts to receive a unit from the_semaphore.
180
 *  If a unit is available or if the RTEMS_NO_WAIT option is enabled in
181
 *  option_set, then the routine returns.  Otherwise, the calling task
182
 *  is blocked until a unit becomes available.
183
 */
184
 
185
boolean _Semaphore_Seize(
186
  Semaphore_Control *the_semaphore,
187
  unsigned32         option_set
188
);
189
 
190
/*
191
 *  _Semaphore_Translate_core_mutex_return_code
192
 *
193
 *  DESCRIPTION:
194
 *
195
 *  This function returns a RTEMS status code based on the mutex
196
 *  status code specified.
197
 */
198
 
199
rtems_status_code _Semaphore_Translate_core_mutex_return_code (
200
  unsigned32 the_mutex_status
201
);
202
 
203
/*
204
 *  _Semaphore_Translate_core_semaphore_return_code
205
 *
206
 *  DESCRIPTION:
207
 *
208
 *  This function returns a RTEMS status code based on the semaphore
209
 *  status code specified.
210
 */
211
 
212
rtems_status_code _Semaphore_Translate_core_semaphore_return_code (
213
  unsigned32 the_mutex_status
214
);
215
 
216
/*PAGE
217
 *
218
 *  _Semaphore_Core_mutex_mp_support
219
 *
220
 *  DESCRIPTION:
221
 *
222
 *  This function processes the global actions necessary for remote
223
 *  accesses to a global semaphore based on a core mutex.  This function
224
 *  is called by the core.
225
 */
226
 
227
#if defined(RTEMS_MULTIPROCESSING)
228
void  _Semaphore_Core_mutex_mp_support (
229
  Thread_Control *the_thread,
230
  rtems_id        id
231
);
232
#endif
233
 
234
/*PAGE
235
 *
236
 *  _Semaphore_Core_mp_support
237
 *
238
 *  DESCRIPTION:
239
 *
240
 *  This function processes the global actions necessary for remote
241
 *  accesses to a global semaphore based on a core semaphore.  This function
242
 *  is called by the core.
243
 */
244
 
245
void  _Semaphore_Core_semaphore_mp_support (
246
  Thread_Control *the_thread,
247
  rtems_id        id
248
);
249
 
250
/*PAGE
251
 *
252
 *  _POSIX_Semaphore_MP_support
253
 *
254
 *  DESCRIPTION:
255
 *
256
 *  XXX
257
 */
258
 
259
void _POSIX_Semaphore_MP_support(
260
  Thread_Control *the_thread,
261
  Objects_Id      id
262
);
263
 
264
#ifndef __RTEMS_APPLICATION__
265
#include <rtems/rtems/sem.inl>
266
#endif
267
#if defined(RTEMS_MULTIPROCESSING)
268
#include <rtems/rtems/semmp.h>
269
#endif
270
 
271
#ifdef __cplusplus
272
}
273
#endif
274
 
275
#endif
276
/*  end of include file */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.