source: rtems/cpukit/rtems/include/rtems/rtems/sem.h @ 426f35f

5
Last change on this file since 426f35f was 426f35f, checked in by Joel Sherrill <joel@…>, on 03/22/16 at 18:15:07

cpukit/rtems/include/rtems/rtems/sem.h: Remove junk in comment

  • Property mode set to 100644
File size: 7.9 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicSem
5 *
6 * @brief Classic Semaphores API
7 *
8 * This include file contains all the constants and structures associated
9 * with the Semaphore Manager. This manager utilizes standard Dijkstra
10 * counting semaphores to provide synchronization and mutual exclusion
11 * capabilities.
12 *
13 * Directives provided are:
14 *
15 * - create a semaphore
16 * - get an ID of a semaphore
17 * - delete a semaphore
18 * - acquire a semaphore
19 * - release a semaphore
20 * - flush a semaphore
21 * - set ceiling priority for a semaphore
22 */
23
24/*
25 * COPYRIGHT (c) 1989-2008, 2016.
26 * On-Line Applications Research Corporation (OAR).
27 *
28 * The license and distribution terms for this file may be
29 * found in the file LICENSE in this distribution or at
30 * http://www.rtems.org/license/LICENSE.
31 */
32
33#ifndef _RTEMS_RTEMS_SEM_H
34#define _RTEMS_RTEMS_SEM_H
35
36#include <rtems/rtems/types.h>
37#include <rtems/rtems/options.h>
38#include <rtems/rtems/support.h>
39#include <rtems/rtems/tasks.h>
40#include <rtems/rtems/attr.h>
41#include <rtems/score/coremutex.h>
42#include <rtems/score/object.h>
43#include <rtems/score/coresem.h>
44#include <rtems/score/mrsp.h>
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/**
51 *  @defgroup ClassicSem Semaphores
52 *
53 *  @ingroup ClassicRTEMS
54 *
55 *  This encapsulates functionality related to the Classic API
56 *  Semaphore Manager.
57 */
58/**@{*/
59
60/**
61 *  The following defines the control block used to manage each semaphore.
62 */
63typedef struct {
64  /** This field is the object management portion of a Semaphore instance. */
65  Objects_Control          Object;
66
67  /**
68   *  This is the Classic API attribute provided to the create directive.
69   *  It is translated into behavioral attributes on the SuperCore Semaphore
70   *  or Mutex instance.
71   */
72  rtems_attribute          attribute_set;
73
74  /**
75   *  This contains the memory associated with the SuperCore Semaphore or
76   *  Mutex instance that provides the primary functionality of each
77   *  Classic API Semaphore instance.  The structure used is dependent
78   *  on the attributes specified by the user on the create directive.
79   *
80   *  @note Only one of these has meaning in a particular Classic API
81   *        Semaphore instance.
82   */
83  union {
84    /**
85     *  This is the SuperCore Mutex instance associated with this Classic
86     *  API Semaphore instance.
87     */
88    CORE_mutex_Control     mutex;
89
90    /**
91     *  This is the SuperCore Semaphore instance associated with this Classic
92     *  API Semaphore instance.
93     */
94    CORE_semaphore_Control semaphore;
95
96#if defined(RTEMS_SMP)
97    MRSP_Control mrsp;
98#endif
99  } Core_control;
100}   Semaphore_Control;
101
102/**
103 *  @brief rtems_semaphore_create
104 *
105 *  This routine implements the rtems_semaphore_create directive.  The
106 *  semaphore will have the name name.  The starting count for
107 *  the semaphore is count.  The attribute_set determines if
108 *  the semaphore is global or local and the thread queue
109 *  discipline.  It returns the id of the created semaphore in ID.
110 */
111rtems_status_code rtems_semaphore_create(
112  rtems_name           name,
113  uint32_t             count,
114  rtems_attribute      attribute_set,
115  rtems_task_priority  priority_ceiling,
116  rtems_id            *id
117);
118
119/**
120 * @brief RTEMS Semaphore Name to Id
121 *
122 * This routine implements the rtems_semaphore_ident directive.
123 * This directive returns the semaphore ID associated with name.
124 * If more than one semaphore is named name, then the semaphore
125 * to which the ID belongs is arbitrary. node indicates the
126 * extent of the search for the ID of the semaphore named name.
127 * The search can be limited to a particular node or allowed to
128 * encompass all nodes.
129 *
130 * @param[in] name is the user defined semaphore name
131 * @param[in] node is(are) the node(s) to be searched
132 * @param[in] id is the pointer to semaphore id
133 *
134 * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and
135 * *id filled in with the semaphore id
136 */
137rtems_status_code rtems_semaphore_ident(
138  rtems_name    name,
139  uint32_t      node,
140  rtems_id     *id
141);
142
143/**
144 * @brief RTEMS Delete Semaphore
145 *
146 * This routine implements the rtems_semaphore_delete directive. The
147 * semaphore indicated by ID is deleted.
148 *
149 * @param[in] id is the semaphore id
150 *
151 * @retval This method returns RTEMS_SUCCESSFUL if there was not an
152 *         error. Otherwise, a status code is returned indicating the
153 *         source of the error.
154 */
155rtems_status_code rtems_semaphore_delete(
156  rtems_id   id
157);
158
159/**
160 * @brief RTEMS Obtain Semaphore
161 *
162 * This routine implements the rtems_semaphore_obtain directive. It
163 * attempts to obtain a unit from the semaphore associated with ID.
164 * If a unit can be allocated, the calling task will return immediately.
165 * If no unit is available, then the task may return immediately or
166 * block waiting for a unit with an optional timeout of timeout
167 * clock ticks. Whether the task blocks or returns immediately
168 * is based on the RTEMS_NO_WAIT option in the option_set.
169 *
170 * @param[in] id is the semaphore id
171 * @param[in] option_set is the wait option
172 * @param[in] timeout is the number of ticks to wait (0 means wait forever)
173 *
174 * @retval This method returns RTEMS_SUCCESSFUL if there was not an
175 *         error. Otherwise, a status code is returned indicating the
176 *         source of the error.
177 */
178rtems_status_code rtems_semaphore_obtain(
179  rtems_id       id,
180  rtems_option   option_set,
181  rtems_interval timeout
182);
183
184/**
185 *  @brief RTEMS Semaphore Release
186 *
187 *  This routine implements the rtems_semaphore_release directive.  It
188 *  frees a unit to the semaphore associated with ID.  If a task was
189 *  blocked waiting for a unit from this semaphore, then that task will
190 *  be readied and the unit given to that task.  Otherwise, the unit
191 *  will be returned to the semaphore.
192 */
193rtems_status_code rtems_semaphore_release(
194  rtems_id   id
195);
196
197/**
198 * @brief RTEMS Semaphore Flush
199 *
200 * This method is the implementation of the flush directive
201 * of the Semaphore Manager.
202 *
203 * This directive allows a thread to flush the threads
204 * pending on the semaphore.
205 *
206 * @param[in] id is the semaphore id
207 *
208 * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful
209 */
210rtems_status_code rtems_semaphore_flush(
211  rtems_id         id
212);
213
214/**
215 * @brief Sets the priority value with respect to the specified scheduler of a
216 * semaphore.
217 *
218 * The special priority value @ref RTEMS_CURRENT_PRIORITY can be used to get
219 * the current priority value without changing it.
220 *
221 * The interpretation of the priority value depends on the protocol of the
222 * semaphore object.
223 *
224 * - The Multiprocessor Resource Sharing Protocol needs a ceiling priority per
225 *   scheduler instance.  This operation can be used to specify these priority
226 *   values.
227 * - For the Priority Ceiling Protocol the ceiling priority is used with this
228 *   operation.
229 * - For other protocols this operation is not defined.
230 *
231 * @param[in] semaphore_id Identifier of the semaphore.
232 * @param[in] scheduler_id Identifier of the scheduler.
233 * @param[in] new_priority The new priority value.  Use
234 * @ref RTEMS_CURRENT_PRIORITY to not set a new priority and only get the
235 * current priority.
236 * @param[out] old_priority Reference to store the old priority value.
237 *
238 * @retval RTEMS_SUCCESSFUL Successful operation.
239 * @retval RTEMS_INVALID_ID Invalid semaphore or scheduler identifier.
240 * @retval RTEMS_INVALID_ADDRESS The old priority reference is @c NULL.
241 * @retval RTEMS_INVALID_PRIORITY The new priority value is invalid.
242 * @retval RTEMS_NOT_DEFINED The set priority operation is not defined for the
243 * protocol of this semaphore object.
244 * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Not supported for remote semaphores.
245 *
246 * @see rtems_scheduler_ident() and rtems_task_set_priority().
247 */
248rtems_status_code rtems_semaphore_set_priority(
249  rtems_id             semaphore_id,
250  rtems_id             scheduler_id,
251  rtems_task_priority  new_priority,
252  rtems_task_priority *old_priority
253);
254
255/**@}*/
256
257#ifdef __cplusplus
258}
259#endif
260
261#endif
262/*  end of include file */
Note: See TracBrowser for help on using the repository browser.