source: rtems/cpukit/score/include/rtems/score/coresem.h @ 355ee7d

4.115
Last change on this file since 355ee7d was 355ee7d, checked in by Alex Ivanov <alexivanov97@…>, on 11/28/12 at 19:57:31

score misc: Clean up Doxygen #3 (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/7982215

  • Property mode set to 100644
File size: 6.9 KB
Line 
1/**
2 *  @file  rtems/score/coresem.h
3 *
4 *  This include file contains all the constants and structures associated
5 *  with the Counting Semaphore Handler.  A counting semaphore is the
6 *  standard Dijkstra binary semaphore used to provide synchronization
7 *  and mutual exclusion capabilities.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2008.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 */
18
19#ifndef _RTEMS_SCORE_CORESEM_H
20#define _RTEMS_SCORE_CORESEM_H
21
22/**
23 *  @defgroup ScoreSemaphore Semaphore Handler
24 *
25 *  @ingroup Score
26 *
27 *  This handler encapsulates functionality which provides the foundation
28 *  Semaphore services used in all of the APIs supported by RTEMS.
29 */
30/**@{*/
31
32#include <rtems/score/thread.h>
33#include <rtems/score/threadq.h>
34#include <rtems/score/priority.h>
35#include <rtems/score/watchdog.h>
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41#if defined(RTEMS_POSIX_API) || defined(RTEMS_MULTIPROCESSING)
42  #define RTEMS_SCORE_CORESEM_ENABLE_SEIZE_BODY
43#endif
44
45/**
46 *  The following type defines the callout which the API provides
47 *  to support global/multiprocessor operations on semaphores.
48 */
49typedef void ( *CORE_semaphore_API_mp_support_callout )(
50                 Thread_Control *,
51                 Objects_Id
52             );
53
54/**
55 *  Blocking disciplines for a semaphore.
56 */
57typedef enum {
58  /** This specifies that threads will wait for the semaphore in FIFO order. */
59  CORE_SEMAPHORE_DISCIPLINES_FIFO,
60  /** This specifies that threads will wait for the semaphore in
61   *  priority order.
62   */
63  CORE_SEMAPHORE_DISCIPLINES_PRIORITY
64}   CORE_semaphore_Disciplines;
65
66/**
67 *  Core Semaphore handler return statuses.
68 */
69typedef enum {
70  /** This status indicates that the operation completed successfully. */
71  CORE_SEMAPHORE_STATUS_SUCCESSFUL,
72  /** This status indicates that the calling task did not want to block
73   *  and the operation was unable to complete immediately because the
74   *  resource was unavailable.
75   */
76  CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT,
77  /** This status indicates that the thread was blocked waiting for an
78   *  operation to complete and the semaphore was deleted.
79   */
80  CORE_SEMAPHORE_WAS_DELETED,
81  /** This status indicates that the calling task was willing to block
82   *  but the operation was unable to complete within the time allotted
83   *  because the resource never became available.
84   */
85  CORE_SEMAPHORE_TIMEOUT,
86  /** This status indicates that an attempt was made to unlock the semaphore
87   *  and this would have made its count greater than that allowed.
88   */
89  CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED
90}   CORE_semaphore_Status;
91
92/**
93 *  @brief Core Semaphore Last Status
94 *
95 *  This is the last status value.
96 */
97#define CORE_SEMAPHORE_STATUS_LAST CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED
98
99/**
100 *  The following defines the control block used to manage the
101 *  attributes of each semaphore.
102 */
103typedef struct {
104  /** This element indicates the maximum count this semaphore may have. */
105  uint32_t                    maximum_count;
106  /** This field indicates whether threads waiting on the semaphore block in
107   *  FIFO or priority order.
108   */
109  CORE_semaphore_Disciplines  discipline;
110}   CORE_semaphore_Attributes;
111
112/**
113 *  The following defines the control block used to manage each
114 *  counting semaphore.
115 */
116typedef struct {
117  /** This field is the Waiting Queue used to manage the set of tasks
118   *  which are blocked waiting to obtain the semaphore.
119   */
120  Thread_queue_Control        Wait_queue;
121  /** This element is the set of attributes which define this instance's
122   *  behavior.
123   */
124  CORE_semaphore_Attributes   Attributes;
125  /** This element contains the current count of this semaphore. */
126  uint32_t                    count;
127}   CORE_semaphore_Control;
128
129/**
130 *  @brief Core Semaphore Initialize
131 *
132 *  DESCRIPTION:
133 *
134 *  This package is the implementation of the CORE Semaphore Handler.
135 *  This core object utilizes standard Dijkstra counting semaphores to provide
136 *  synchronization and mutual exclusion capabilities.
137 *
138 *  This routine initializes the semaphore based on the parameters passed.
139 *
140 *  @param[in] the_semaphore is the semaphore to initialize
141 *  @param[in] the_semaphore_attributes define the behavior of this instance
142 *  @param[in] initial_value is the initial count of the semaphore
143 */
144void _CORE_semaphore_Initialize(
145  CORE_semaphore_Control       *the_semaphore,
146  CORE_semaphore_Attributes    *the_semaphore_attributes,
147  uint32_t                      initial_value
148);
149
150#if defined(RTEMS_SCORE_CORESEM_ENABLE_SEIZE_BODY)
151  /**
152   *  This routine attempts to receive a unit from @a the_semaphore.
153   *  If a unit is available or if the wait flag is false, then the routine
154   *  returns.  Otherwise, the calling task is blocked until a unit becomes
155   *  available.
156   *
157   *  @param[in] the_semaphore is the semaphore to seize
158   *  @param[in] id is the Id of the API level Semaphore object associated
159   *         with this instance of a SuperCore Semaphore
160   *  @param[in] wait indicates if the caller is willing to block
161   *  @param[in] timeout is the number of ticks the calling thread is willing
162   *         to wait if @a wait is true.
163   */
164  void _CORE_semaphore_Seize(
165    CORE_semaphore_Control  *the_semaphore,
166    Objects_Id               id,
167    bool                     wait,
168    Watchdog_Interval        timeout
169  );
170#endif
171
172/**
173 *  This routine frees a unit to the semaphore.  If a task was blocked waiting
174 *  for a unit from this semaphore, then that task will be readied and the unit
175 *  given to that task.  Otherwise, the unit will be returned to the semaphore.
176 *
177 *  @param[in] the_semaphore is the semaphore to surrender
178 *  @param[in] id is the Id of the API level Semaphore object associated
179 *         with this instance of a SuperCore Semaphore
180 *  @param[in] api_semaphore_mp_support is the routine to invoke if the
181 *         thread unblocked is remote
182 *
183 *  @return an indication of whether the routine succeeded or failed
184 */
185CORE_semaphore_Status _CORE_semaphore_Surrender(
186  CORE_semaphore_Control                *the_semaphore,
187  Objects_Id                             id,
188  CORE_semaphore_API_mp_support_callout  api_semaphore_mp_support
189);
190
191/**
192 *  This routine assists in the deletion of a semaphore by flushing the
193 *  associated wait queue.
194 *
195 *  @param[in] the_semaphore is the semaphore to flush
196 *  @param[in] remote_extract_callout is the routine to invoke if the
197 *         thread unblocked is remote
198 *  @param[in] status is the status to be returned to the unblocked thread
199 */
200void _CORE_semaphore_Flush(
201  CORE_semaphore_Control         *the_semaphore,
202  Thread_queue_Flush_callout      remote_extract_callout,
203  uint32_t                        status
204);
205
206#ifndef __RTEMS_APPLICATION__
207#include <rtems/score/coresem.inl>
208#endif
209
210#ifdef __cplusplus
211}
212#endif
213
214/**@}*/
215
216#endif
217/*  end of include file */
Note: See TracBrowser for help on using the repository browser.