source: rtems/cpukit/score/include/rtems/score/corerwlock.h @ 18ca4e8

4.104.114.95
Last change on this file since 18ca4e8 was 18ca4e8, checked in by Joel Sherrill <joel.sherrill@…>, on 01/29/08 at 23:58:17

2008-01-29 Joel Sherrill <joel.sherrill@…>

  • score/Doxyfile: Update to latest Doxygen format.
  • score/include/rtems/score/apimutex.h, score/include/rtems/score/corebarrier.h, score/include/rtems/score/coremutex.h, score/include/rtems/score/corerwlock.h, score/include/rtems/score/heap.h, score/include/rtems/score/object.h, score/include/rtems/score/protectedheap.h, score/include/rtems/score/thread.h, score/include/rtems/score/threadsync.h, score/include/rtems/score/tod.h, score/inline/rtems/score/corerwlock.inl, score/inline/rtems/score/corespinlock.inl: Remove most doxygen warnings.
  • Property mode set to 100644
File size: 6.7 KB
Line 
1/**
2 *  @file  rtems/score/corerwlock.h
3 *
4 *  This include file contains all the constants and structures associated
5 *  with the RWLock Handler.
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2008.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#ifndef _RTEMS_SCORE_CORERWLOCK_H
20#define _RTEMS_SCORE_CORERWLOCK_H
21
22/**
23 *  @defgroup ScoreRWLock RWLock Handler
24 *
25 *  This handler encapsulates functionality which provides the foundation
26 *  RWLock services used in all of the APIs supported by RTEMS.
27 */
28/**@{*/
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include <rtems/score/thread.h>
35#include <rtems/score/threadq.h>
36#include <rtems/score/priority.h>
37#include <rtems/score/watchdog.h>
38
39/**
40 *  The following type defines the callout which the API provides
41 *  to support global/multiprocessor operations on RWLocks.
42 */
43typedef void ( *CORE_RWLock_API_mp_support_callout )(
44                 Thread_Control *,
45                 Objects_Id
46             );
47
48/**
49 *  RWLock State.
50 */
51typedef enum {
52  /** This indicates the the RWLock is not currently locked.
53   */
54  CORE_RWLOCK_UNLOCKED,
55  /** This indicates the the RWLock is currently locked for reading.
56   */
57  CORE_RWLOCK_LOCKED_FOR_READING,
58  /** This indicates the the RWLock is currently locked for reading.
59   */
60  CORE_RWLOCK_LOCKED_FOR_WRITING
61}   CORE_RWLock_States;
62
63/**
64 *  Core RWLock handler return statuses.
65 */
66typedef enum {
67  /** This status indicates that the operation completed successfully. */
68  CORE_RWLOCK_SUCCESSFUL,
69  /** This status indicates that the thread was blocked waiting for an */
70  CORE_RWLOCK_WAS_DELETED,
71  /** This status indicates that the rwlock was not immediately available. */
72  CORE_RWLOCK_UNAVAILABLE,
73  /** This status indicates that the calling task was willing to block
74   *  but the operation was unable to complete within the time allotted
75   *  because the resource never became available.
76   */
77  CORE_RWLOCK_TIMEOUT
78}   CORE_RWLock_Status;
79
80/** This is the last status value.
81 */
82#define CORE_RWLOCK_STATUS_LAST CORE_RWLOCK_TIMEOUT
83
84/**
85 *  This is used to denote that a thread is blocking waiting for
86 *  read-only access to the RWLock.
87 */
88#define CORE_RWLOCK_THREAD_WAITING_FOR_READ  0
89
90/**
91 *  This is used to denote that a thread is blocking waiting for
92 *  write-exclusive access to the RWLock.
93 */
94#define CORE_RWLOCK_THREAD_WAITING_FOR_WRITE 1
95
96/**
97 *  The following defines the control block used to manage the
98 *  attributes of each RWLock.
99 */
100typedef struct {
101  /** This field indicates XXX.
102   */
103  int XXX;
104}   CORE_RWLock_Attributes;
105
106/**
107 *  The following defines the control block used to manage each
108 *  RWLock.
109 */
110typedef struct {
111  /** This field is the Waiting Queue used to manage the set of tasks
112   *  which are blocked waiting for the RWLock to be released.
113   */
114  Thread_queue_Control     Wait_queue;
115  /** This element is the set of attributes which define this instance's
116   *  behavior.
117   */
118  CORE_RWLock_Attributes  Attributes;
119  /** This element is the current state of the RWLock.
120   */
121  CORE_RWLock_States       current_state;
122  /** This element contains the current number of thread waiting for this
123   *  RWLock to be released. */
124  uint32_t                 number_of_readers;
125}   CORE_RWLock_Control;
126
127/**
128 *  This routine initializes the RWLock based on the parameters passed.
129 *
130 *  @param[in] the_rwlock is the RWLock to initialize
131 *  @param[in] the_rwlock_attributes define the behavior of this instance
132 */
133void _CORE_RWLock_Initialize(
134  CORE_RWLock_Control       *the_rwlock,
135  CORE_RWLock_Attributes    *the_rwlock_attributes
136);
137
138/**
139 *  This routine attempts to obtain the RWLock for read access.
140 *
141 *  @param[in] the_rwlock is the RWLock to wait for
142 *  @param[in] id is the id of the object being waited upon
143 *  @param[in] wait is TRUE if the calling thread is willing to wait
144 *  @param[in] timeout is the number of ticks the calling thread is willing
145 *         to wait if @a wait is TRUE.
146 *  @param[in] api_rwlock_mp_support is the routine to invoke if the
147 *         thread unblocked is remote
148 *
149 * @note Status is returned via the thread control block.
150 */
151void _CORE_RWLock_Obtain_for_reading(
152  CORE_RWLock_Control                 *the_rwlock,
153  Objects_Id                           id,
154  boolean                              wait,
155  Watchdog_Interval                    timeout,
156  CORE_RWLock_API_mp_support_callout   api_rwlock_mp_support
157);
158
159/**
160 *  This routine attempts to obtain the RWLock for write exclusive access.
161 *
162 *  @param[in] the_rwlock is the RWLock to wait for
163 *  @param[in] id is the id of the object being waited upon
164 *  @param[in] wait is TRUE if the calling thread is willing to wait
165 *  @param[in] timeout is the number of ticks the calling thread is willing
166 *         to wait if @a wait is TRUE.
167 *  @param[in] api_rwlock_mp_support is the routine to invoke if the
168 *         thread unblocked is remote
169 *
170 * @note Status is returned via the thread control block.
171 */
172void _CORE_RWLock_Obtain_for_writing(
173  CORE_RWLock_Control                 *the_rwlock,
174  Objects_Id                           id,
175  boolean                              wait,
176  Watchdog_Interval                    timeout,
177  CORE_RWLock_API_mp_support_callout   api_rwlock_mp_support
178);
179
180/**
181 *  This routine manually releases the RWLock.  All of the threads waiting
182 *  for the RWLock will be readied.
183 *
184 *  @param[in] the_rwlock is the RWLock to surrender
185 *
186 *  @return Status is returned to indicate successful or failure.
187 */
188CORE_RWLock_Status _CORE_RWLock_Release(
189  CORE_RWLock_Control                *the_rwlock
190);
191
192/**
193 *  This routine assists in the deletion of a RWLock by flushing the
194 *  associated wait queue.
195 *
196 *  @param[in] _the_rwlock is the RWLock to flush
197 *  @param[in] _remote_extract_callout is the routine to invoke if the
198 *         thread unblocked is remote
199 *  @param[in] _status is the status to be returned to the unblocked thread
200 */
201#define _CORE_RWLock_Flush( _the_rwlock, _remote_extract_callout, _status) \
202  _Thread_queue_Flush( \
203    &((_the_rwlock)->Wait_queue), \
204    (_remote_extract_callout), \
205    (_status) \
206  )
207
208/**
209 *  @brief RWLock Specific Thread Queue Timeout
210 *
211 *  This routine processes a thread which timeouts while waiting on
212 *  an RWLock's thread queue. It is called by the watchdog handler.
213 *
214 *  @param[in] id is the Id of thread to timeout
215 *  @param[in] ignored is an unused pointer to a caller defined area
216 */
217
218void _CORE_RWLock_Timeout(
219  Objects_Id  id,
220  void       *ignored
221);
222
223
224#ifndef __RTEMS_APPLICATION__
225#include <rtems/score/corerwlock.inl>
226#endif
227
228#ifdef __cplusplus
229}
230#endif
231
232/**@}*/
233
234#endif
235/*  end of include file */
Note: See TracBrowser for help on using the repository browser.