source: rtems/cpukit/rtems/include/rtems/rtems/sem.h @ 7f6a24ab

4.104.114.84.95
Last change on this file since 7f6a24ab was 7f6a24ab, checked in by Joel Sherrill <joel.sherrill@…>, on 08/28/95 at 15:30:29

Added unused priority ceiling parameter to rtems_semaphore_create.

Rearranged code to created thread handler routines to initialize,
start, restart, and "close/delete" a thread.

Made internal threads their own object class. This now uses the
thread support routines for starting and initializing a thread.

Insured deleted tasks are freed to the Inactive pool associated with the
correct Information block.

Added an RTEMS API specific data area to the thread control block.

Beginnings of removing the word "rtems" from the core.

  • 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, 1990, 1991, 1992, 1993, 1994.
17 *  On-Line Applications Research Corporation (OAR).
18 *  All rights assigned to U.S. Government, 1994.
19 *
20 *  This material may be reproduced by or for the U.S. Government pursuant
21 *  to the copyright license under the clause at DFARS 252.227-7013.  This
22 *  notice must appear in all copies of this file and its derivatives.
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.h>
35#include <rtems/attr.h>
36#include <rtems/object.h>
37#include <rtems/threadq.h>
38
39/*
40 *  The following defines the control block used to manage each semaphore.
41 */
42
43typedef struct {
44  Objects_Control       Object;
45  Thread_queue_Control  Wait_queue;
46  rtems_attribute    attribute_set;
47  unsigned32            count;
48  unsigned32            nest_count;
49  Thread_Control       *holder;
50  Objects_Id            holder_id;
51}   Semaphore_Control;
52
53/*
54 *  The following defines the information control block used to manage
55 *  this class of objects.
56 */
57
58EXTERN Objects_Information  _Semaphore_Information;
59
60/*
61 *  _Semaphore_Manager_initialization
62 *
63 *  DESCRIPTION:
64 *
65 *  This routine performs the initialization necessary for this manager.
66 */
67
68void _Semaphore_Manager_initialization(
69  unsigned32 maximum_semaphores
70);
71
72/*
73 *  rtems_semaphore_create
74 *
75 *  DESCRIPTION:
76 *
77 *  This routine implements the rtems_semaphore_create directive.  The
78 *  semaphore will have the name name.  The starting count for
79 *  the semaphore is count.  The attribute_set determines if
80 *  the semaphore is global or local and the thread queue
81 *  discipline.  It returns the id of the created semaphore in ID.
82 */
83
84rtems_status_code rtems_semaphore_create(
85  rtems_name            name,
86  unsigned32            count,
87  rtems_attribute       attribute_set,
88  rtems_task_priority   priority_ceiling,
89  Objects_Id           *id
90);
91
92/*
93 *  rtems_semaphore_ident
94 *
95 *  DESCRIPTION:
96 *
97 *  This routine implements the rtems_semaphore_ident directive.
98 *  This directive returns the semaphore ID associated with name.
99 *  If more than one semaphore is named name, then the semaphore
100 *  to which the ID belongs is arbitrary.  node indicates the
101 *  extent of the search for the ID of the semaphore named name.
102 *  The search can be limited to a particular node or allowed to
103 *  encompass all nodes.
104 */
105
106rtems_status_code rtems_semaphore_ident(
107  rtems_name    name,
108  unsigned32    node,
109  Objects_Id   *id
110);
111
112/*
113 *  rtems_semaphore_delete
114 *
115 *  DESCRIPTION:
116 *
117 *  This routine implements the rtems_semaphore_delete directive.  The
118 *  semaphore indicated by ID is deleted.
119 */
120
121rtems_status_code rtems_semaphore_delete(
122  Objects_Id id
123);
124
125/*
126 *  rtems_semaphore_obtain
127 *
128 *  DESCRIPTION:
129 *
130 *  This routine implements the rtems_semaphore_obtain directive.  It
131 *  attempts to obtain a unit from the semaphore associated with ID.
132 *  If a unit can be allocated, the calling task will return immediately.
133 *  If no unit is available, then the task may return immediately or
134 *  block waiting for a unit with an optional timeout of timeout
135 *  clock ticks.  Whether the task blocks or returns immediately
136 *  is based on the RTEMS_NO_WAIT option in the option_set.
137 */
138
139rtems_status_code rtems_semaphore_obtain(
140  Objects_Id        id,
141  unsigned32        option_set,
142  rtems_interval timeout
143);
144
145/*
146 *  rtems_semaphore_release
147 *
148 *  DESCRIPTION:
149 *
150 *  This routine implements the rtems_semaphore_release directive.  It
151 *  frees a unit to the semaphore associated with ID.  If a task was
152 *  blocked waiting for a unit from this semaphore, then that task will
153 *  be readied and the unit given to that task.  Otherwise, the unit
154 *  will be returned to the semaphore.
155 */
156
157rtems_status_code rtems_semaphore_release(
158  Objects_Id id
159);
160
161/*
162 *  _Semaphore_Seize
163 *
164 *  DESCRIPTION:
165 *
166 *  This routine attempts to receive a unit from the_semaphore.
167 *  If a unit is available or if the RTEMS_NO_WAIT option is enabled in
168 *  option_set, then the routine returns.  Otherwise, the calling task
169 *  is blocked until a unit becomes available.
170 */
171
172boolean _Semaphore_Seize(
173  Semaphore_Control *the_semaphore,
174  unsigned32         option_set
175);
176
177/*
178 *  _Semaphore_Allocate
179 *
180 *  DESCRIPTION:
181 *
182 *  This function allocates a semaphore control block from
183 *  the inactive chain of free semaphore control blocks.
184 */
185
186STATIC INLINE Semaphore_Control *_Semaphore_Allocate( void );
187
188/*
189 *  _Semaphore_Free
190 *
191 *  DESCRIPTION:
192 *
193 *  This routine frees a semaphore control block to the
194 *  inactive chain of free semaphore control blocks.
195 */
196
197STATIC INLINE void _Semaphore_Free (
198  Semaphore_Control *the_semaphore
199);
200
201/*
202 *  _Semaphore_Get
203 *
204 *  DESCRIPTION:
205 *
206 *  This function maps semaphore IDs to semaphore control blocks.
207 *  If ID corresponds to a local semaphore, then it returns
208 *  the_semaphore control pointer which maps to ID and location
209 *  is set to OBJECTS_LOCAL.  if the semaphore ID is global and
210 *  resides on a remote node, then location is set to OBJECTS_REMOTE,
211 *  and the_semaphore is undefined.  Otherwise, location is set
212 *  to OBJECTS_ERROR and the_semaphore is undefined.
213 */
214
215STATIC INLINE Semaphore_Control *_Semaphore_Get (
216  Objects_Id         id,
217  Objects_Locations *location
218);
219
220/*
221 *  _Semaphore_Is_null
222 *
223 *  DESCRIPTION:
224 *
225 *  This function returns TRUE if the_semaphore is NULL and FALSE otherwise.
226 */
227
228STATIC INLINE boolean _Semaphore_Is_null (
229  Semaphore_Control *the_semaphore
230);
231
232#include <rtems/sem.inl>
233#include <rtems/semmp.h>
234
235#ifdef __cplusplus
236}
237#endif
238
239#endif
240/*  end of include file */
Note: See TracBrowser for help on using the repository browser.