source: rtems/cpukit/include/rtems/rtems/sem.h @ 739df1f5

5
Last change on this file since 739df1f5 was 739df1f5, checked in by Sebastian Huber <sebastian.huber@…>, on 11/08/18 at 09:45:44

rtems: Move internal structures to semdata.h

Update #3598.

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