source: rtems/cpukit/rtems/include/rtems/rtems/sem.h @ 60ceb613

4.115
Last change on this file since 60ceb613 was 60ceb613, checked in by Alex Ivanov <alexivanov97@…>, on 12/05/12 at 23:15:32

rtems misc: Clean up Doxygen GCI Task #6

http://www.google-melange.com/gci/task/view/google/gci2012/8019205

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