source: rtems/cpukit/rtems/include/rtems/rtems/sem.h @ c85ab23

4.104.115
Last change on this file since c85ab23 was c85ab23, checked in by Joel Sherrill <joel.sherrill@…>, on 08/05/09 at 18:17:12

2009-08-05 Sebastian Huber <sebastian.huber@…>

  • libcsupport/include/rtems/libio_.h, libcsupport/src/fs_null_handlers.c: Null handlers are now const.
  • libi2c/libi2c.c, libi2c/libi2c.h: Documentation. Do not create semaphores on the fly.
  • cpukit/libblock/src/bdpart.c: Fixed format specifier.
  • cpukit/libblock/include/rtems/bdbuf.h, rtems/include/rtems.h, rtems/include/rtems/rtems/asr.h, rtems/include/rtems/rtems/attr.h, rtems/include/rtems/rtems/barrier.h, rtems/include/rtems/rtems/barriermp.h, rtems/include/rtems/rtems/cache.h, rtems/include/rtems/rtems/clock.h, rtems/include/rtems/rtems/config.h, rtems/include/rtems/rtems/dpmem.h, rtems/include/rtems/rtems/event.h, rtems/include/rtems/rtems/eventmp.h, rtems/include/rtems/rtems/eventset.h, rtems/include/rtems/rtems/intr.h, rtems/include/rtems/rtems/message.h, rtems/include/rtems/rtems/modes.h, rtems/include/rtems/rtems/mp.h, rtems/include/rtems/rtems/msgmp.h, rtems/include/rtems/rtems/object.h, rtems/include/rtems/rtems/part.h, rtems/include/rtems/rtems/partmp.h, rtems/include/rtems/rtems/ratemon.h, rtems/include/rtems/rtems/region.h, rtems/include/rtems/rtems/regionmp.h, rtems/include/rtems/rtems/rtemsapi.h, rtems/include/rtems/rtems/sem.h, rtems/include/rtems/rtems/semmp.h, rtems/include/rtems/rtems/signal.h, rtems/include/rtems/rtems/signalmp.h, rtems/include/rtems/rtems/status.h, rtems/include/rtems/rtems/support.h, rtems/include/rtems/rtems/taskmp.h, rtems/include/rtems/rtems/tasks.h, rtems/include/rtems/rtems/timer.h, rtems/include/rtems/rtems/types.h, rtems/inline/rtems/rtems/support.inl: Documentation.
  • include/rtems/irq-extension.h: Documentation. Added API for interrupt servers.
  • Property mode set to 100644
File size: 6.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 *  $Id$
26 */
27
28#ifndef _RTEMS_RTEMS_SEM_H
29#define _RTEMS_RTEMS_SEM_H
30
31/**
32 *  This constant is defined to extern most of the time when using
33 *  this header file.  However by defining it to nothing, the data
34 *  declared in this header file can be instantiated.  This is done
35 *  in a single per manager file.
36 */
37#ifndef RTEMS_SEM_EXTERN
38#define RTEMS_SEM_EXTERN extern
39#endif
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45#include <rtems/rtems/types.h>
46#include <rtems/rtems/options.h>
47#include <rtems/rtems/support.h>
48#include <rtems/rtems/tasks.h>
49#include <rtems/rtems/attr.h>
50#include <rtems/score/coremutex.h>
51#include <rtems/score/object.h>
52#include <rtems/score/coresem.h>
53
54/**
55 *  @defgroup ClassicSem Semaphores
56 *
57 *  @ingroup ClassicRTEMS
58 *
59 *  This encapsulates functionality related to the Classic API
60 *  Semaphore Manager.
61 */
62/**@{*/
63
64/**
65 *  The following defines the control block used to manage each semaphore.
66 */
67typedef struct {
68  /** This field is the object management portion of a Semaphore instance. */
69  Objects_Control          Object;
70
71  /**
72   *  This is the Classic API attribute provided to the create directive.
73   *  It is translated into behavioral attributes on the SuperCore Semaphore
74   *  or Mutex instance.
75   */
76  rtems_attribute          attribute_set;
77
78  /**
79   *  This contains the memory associated with the SuperCore Semaphore or
80   *  Mutex instance that provides the primary functionality of each
81   *  Classic API Semaphore instance.  The structure used is dependent
82   *  on the attributes specified by the user on the create directive.
83   *
84   *  @note Only one of these has meaning in a particular Classic API
85   *        Semaphore instance.
86   */
87  union {
88    /**
89     *  This is the SuperCore Mutex instance associated with this Classic
90     *  API Semaphore instance.
91     */
92    CORE_mutex_Control     mutex;
93
94    /**
95     *  This is the SuperCore Semaphore instance associated with this Classic
96     *  API Semaphore instance.
97     */
98    CORE_semaphore_Control semaphore;
99  } Core_control;
100}   Semaphore_Control;
101
102/**
103 *  The following defines the information control block used to manage
104 *  this class of objects.
105 */
106RTEMS_SEM_EXTERN Objects_Information  _Semaphore_Information;
107
108/**
109 *  @brief Semaphore_Manager_initialization
110 *
111 *  This routine performs the initialization necessary for this manager.
112 */
113void _Semaphore_Manager_initialization(void);
114
115/**
116 *  @brief rtems_semaphore_create
117 *
118 *  This routine implements the rtems_semaphore_create directive.  The
119 *  semaphore will have the name name.  The starting count for
120 *  the semaphore is count.  The attribute_set determines if
121 *  the semaphore is global or local and the thread queue
122 *  discipline.  It returns the id of the created semaphore in ID.
123 */
124rtems_status_code rtems_semaphore_create(
125  rtems_name           name,
126  uint32_t             count,
127  rtems_attribute      attribute_set,
128  rtems_task_priority  priority_ceiling,
129  rtems_id            *id
130);
131
132/**
133 *  @brief rtems_semaphore_ident
134 *
135 *  This routine implements the rtems_semaphore_ident directive.
136 *  This directive returns the semaphore ID associated with name.
137 *  If more than one semaphore is named name, then the semaphore
138 *  to which the ID belongs is arbitrary.  node indicates the
139 *  extent of the search for the ID of the semaphore named name.
140 *  The search can be limited to a particular node or allowed to
141 *  encompass all nodes.
142 */
143rtems_status_code rtems_semaphore_ident(
144  rtems_name    name,
145  uint32_t      node,
146  rtems_id     *id
147);
148
149/**
150 *  @brief rtems_semaphore_delete
151 *
152 *  This routine implements the rtems_semaphore_delete directive.  The
153 *  semaphore indicated by ID is deleted.
154 */
155rtems_status_code rtems_semaphore_delete(
156  rtems_id   id
157);
158
159/**
160 *  @brief rtems_semaphore_obtain
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 */
170rtems_status_code rtems_semaphore_obtain(
171  rtems_id       id,
172  rtems_option   option_set,
173  rtems_interval timeout
174);
175
176/**
177 *  @brief rtems_semaphore_release
178 *
179 *  This routine implements the rtems_semaphore_release directive.  It
180 *  frees a unit to the semaphore associated with ID.  If a task was
181 *  blocked waiting for a unit from this semaphore, then that task will
182 *  be readied and the unit given to that task.  Otherwise, the unit
183 *  will be returned to the semaphore.
184 */
185rtems_status_code rtems_semaphore_release(
186  rtems_id   id
187);
188
189/**
190 *  @brief rtems_semaphore_flush
191 *  pending on the semaphore.
192 */
193rtems_status_code rtems_semaphore_flush(
194  rtems_id         id
195);
196
197/**
198 *  @brief _Semaphore_Seize
199 *
200 *  This routine attempts to receive a unit from the_semaphore.
201 *  If a unit is available or if the RTEMS_NO_WAIT option is enabled in
202 *  option_set, then the routine returns.  Otherwise, the calling task
203 *  is blocked until a unit becomes available.
204 */
205bool _Semaphore_Seize(
206  Semaphore_Control *the_semaphore,
207  uint32_t           option_set
208);
209
210/**
211 *  @brief _Semaphore_Translate_core_mutex_return_code
212 *
213 *  This function returns a RTEMS status code based on the mutex
214 *  status code specified.
215 */
216rtems_status_code _Semaphore_Translate_core_mutex_return_code (
217  uint32_t   the_mutex_status
218);
219
220/**
221 *  @brief _Semaphore_Translate_core_semaphore_return_code
222 *
223 *  This function returns a RTEMS status code based on the semaphore
224 *  status code specified.
225 */
226rtems_status_code _Semaphore_Translate_core_semaphore_return_code (
227  uint32_t   the_mutex_status
228);
229
230#ifndef __RTEMS_APPLICATION__
231#include <rtems/rtems/sem.inl>
232#endif
233#if defined(RTEMS_MULTIPROCESSING)
234#include <rtems/rtems/semmp.h>
235#endif
236
237#ifdef __cplusplus
238}
239#endif
240
241/**@}*/
242
243#endif
244/*  end of include file */
Note: See TracBrowser for help on using the repository browser.