source: rtems/cpukit/rtems/include/rtems/rtems/sem.h @ 52adc808

4.115
Last change on this file since 52adc808 was 52adc808, checked in by Alex Ivanov <alexivanov97@…>, on 12/02/12 at 16:03:09

score misc: Clean up Doxygen #12 (GCI 2012)

This patch is a task from GCI 2012 which improves the Doxygen
comments in the RTEMS source.

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

  • Property mode set to 100644
File size: 6.9 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_ident
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 */
141rtems_status_code rtems_semaphore_ident(
142  rtems_name    name,
143  uint32_t      node,
144  rtems_id     *id
145);
146
147/**
148 *  @brief rtems_semaphore_delete
149 *
150 *  This routine implements the rtems_semaphore_delete directive.  The
151 *  semaphore indicated by ID is deleted.
152 */
153rtems_status_code rtems_semaphore_delete(
154  rtems_id   id
155);
156
157/**
158 *  @brief rtems_semaphore_obtain
159 *
160 *  This routine implements the rtems_semaphore_obtain directive.  It
161 *  attempts to obtain a unit from the semaphore associated with ID.
162 *  If a unit can be allocated, the calling task will return immediately.
163 *  If no unit is available, then the task may return immediately or
164 *  block waiting for a unit with an optional timeout of timeout
165 *  clock ticks.  Whether the task blocks or returns immediately
166 *  is based on the RTEMS_NO_WAIT option in the option_set.
167 */
168rtems_status_code rtems_semaphore_obtain(
169  rtems_id       id,
170  rtems_option   option_set,
171  rtems_interval timeout
172);
173
174/**
175 *  @brief rtems_semaphore_release
176 *
177 *  This routine implements the rtems_semaphore_release directive.  It
178 *  frees a unit to the semaphore associated with ID.  If a task was
179 *  blocked waiting for a unit from this semaphore, then that task will
180 *  be readied and the unit given to that task.  Otherwise, the unit
181 *  will be returned to the semaphore.
182 */
183rtems_status_code rtems_semaphore_release(
184  rtems_id   id
185);
186
187/**
188 *  @brief RTEMS Semaphore Flush
189 *
190 *  DESCRIPTION:
191 *  This package is the implementation of the flush directive
192 *  of the Semaphore Manager.
193 *
194 *  This directive allows a thread to flush the threads
195 *  pending on the semaphore.
196 *
197 *  @param[in] id is the semaphore id
198 *
199 *  @return RTEMS_SUCCESSFUL if successful or error code if unsuccessful
200 */
201rtems_status_code rtems_semaphore_flush(
202  rtems_id         id
203);
204
205/**
206 *  @brief _Semaphore_Seize
207 *
208 *  This routine attempts to receive a unit from the_semaphore.
209 *  If a unit is available or if the RTEMS_NO_WAIT option is enabled in
210 *  option_set, then the routine returns.  Otherwise, the calling task
211 *  is blocked until a unit becomes available.
212 */
213bool _Semaphore_Seize(
214  Semaphore_Control *the_semaphore,
215  uint32_t           option_set
216);
217
218/**
219 *  @brief _Semaphore_Translate_core_mutex_return_code
220 *
221 *  This function returns a RTEMS status code based on the mutex
222 *  status code specified.
223 */
224rtems_status_code _Semaphore_Translate_core_mutex_return_code (
225  uint32_t   the_mutex_status
226);
227
228/**
229 *  @brief _Semaphore_Translate_core_semaphore_return_code
230 *
231 *  This function returns a RTEMS status code based on the semaphore
232 *  status code specified.
233 */
234rtems_status_code _Semaphore_Translate_core_semaphore_return_code (
235  uint32_t   the_mutex_status
236);
237
238#ifndef __RTEMS_APPLICATION__
239#include <rtems/rtems/sem.inl>
240#endif
241#if defined(RTEMS_MULTIPROCESSING)
242#include <rtems/rtems/semmp.h>
243#endif
244
245#ifdef __cplusplus
246}
247#endif
248
249/**@}*/
250
251#endif
252/*  end of include file */
Note: See TracBrowser for help on using the repository browser.