source: rtems/cpukit/score/include/rtems/score/corespinlock.h @ d4d7899

4.115
Last change on this file since d4d7899 was d4d7899, checked in by Christopher Kerl <zargyyoyo@…>, on 11/28/12 at 19:31:53

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

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/**
2 *  @file  rtems/score/corespinlock.h
3 *
4 *  This include file contains all the constants and structures associated
5 *  with the Spinlock Handler.
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2006.
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
17#ifndef _RTEMS_SCORE_CORESPINLOCK_H
18#define _RTEMS_SCORE_CORESPINLOCK_H
19
20/**
21 *  @defgroup ScoreSpinlock Spinlock Handler
22 *
23 *  @ingroup Score
24 *
25 *  This handler encapsulates functionality which provides the foundation
26 *  Spinlock 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/priority.h>
36
37/**
38 *  Core Spinlock handler return statuses.
39 */
40typedef enum {
41  /** This status indicates that the operation completed successfully. */
42  CORE_SPINLOCK_SUCCESSFUL,
43  /** This status indicates that the current thread already holds the spinlock.
44   *  An attempt to relock it will result in deadlock.
45   */
46  CORE_SPINLOCK_HOLDER_RELOCKING,
47  /** This status indicates that the current thread is attempting to unlock a
48   *  spinlock that is held by another thread.
49   */
50  CORE_SPINLOCK_NOT_HOLDER,
51  /** This status indicates that a thread reached the limit of time it
52   *  was willing to wait on the spin lock.
53   */
54  CORE_SPINLOCK_TIMEOUT,
55  /** This status indicates that a thread is currently waiting for this
56   *  spin lock.
57   */
58  CORE_SPINLOCK_IS_BUSY,
59  /** This status indicates that the spinlock is currently locked and thus
60   *  unavailable.
61   */
62  CORE_SPINLOCK_UNAVAILABLE,
63  /** This status indicates that the spinlock is not currently locked and thus
64   *  should not be released.
65   */
66  CORE_SPINLOCK_NOT_LOCKED
67}   CORE_spinlock_Status;
68
69/** This is a shorthand for the last status code. */
70#define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_NOT_LOCKED
71
72/** This indicates the lock is available. */
73#define CORE_SPINLOCK_UNLOCKED 0
74
75/** This indicates the lock is unavailable. */
76#define CORE_SPINLOCK_LOCKED   1
77
78/**
79 *  The following defines the control block used to manage the
80 *  attributes of each spinlock.
81 */
82typedef struct {
83  /** This element indicates XXX
84   */
85  uint32_t                  XXX;
86}   CORE_spinlock_Attributes;
87
88/**
89 *  The following defines the control block used to manage each
90 *  spinlock.
91 */
92typedef struct {
93  /** XXX may not be needed */
94  CORE_spinlock_Attributes  Attributes;
95
96  /** This field is the lock.
97   */
98  volatile uint32_t     lock;
99
100  /** This field is a count of the current number of threads using
101   *  this spinlock.  It includes the thread holding the lock as well
102   *  as those waiting.
103   */
104  volatile uint32_t     users;
105
106  /** This field is the Id of the thread holding the lock.  It may or may
107   *  not be the thread which acquired it.
108   */
109  volatile Objects_Id   holder;
110}   CORE_spinlock_Control;
111
112/**
113 *  @brief Initialized a spinlock
114 *
115 *  This routine initializes the spinlock based on the parameters passed.
116 *
117 *  @param[in] the_spinlock is the spinlock control block to initialize
118 *  @param[in] the_spinlock_attributes define the behavior of this instance
119 */
120void _CORE_spinlock_Initialize(
121  CORE_spinlock_Control       *the_spinlock,
122  CORE_spinlock_Attributes    *the_spinlock_attributes
123);
124
125/**
126 *  This routine wait for the spinlock to be released.  If the spinlock
127 *  is set to automatic and this is the appropriate thread, then it returns
128 *  immediately.  Otherwise, the calling thread is blocked until the spinlock
129 *  is released.
130 *
131 *  @param[in] the_spinlock is the spinlock to wait for
132 *  @param[in] wait is true if willing to wait
133 *  @param[in] timeout is the maximum number of ticks to spin (0 is forever)
134 *
135 * @return A status is returned which indicates the success or failure of
136 *         this operation.
137 */
138CORE_spinlock_Status _CORE_spinlock_Wait(
139  CORE_spinlock_Control  *the_spinlock,
140  bool                    wait,
141  Watchdog_Interval       timeout
142);
143
144/**
145 * @brief Manually release Spinlock
146 *
147 *  This routine manually releases the spinlock.  All of the threads waiting
148 *  for the spinlock will be readied.
149 *
150 *  @param[in] the_spinlock is the spinlock to surrender
151 */
152CORE_spinlock_Status _CORE_spinlock_Release(
153  CORE_spinlock_Control *the_spinlock
154);
155
156#ifndef __RTEMS_APPLICATION__
157#include <rtems/score/corespinlock.inl>
158#endif
159
160#ifdef __cplusplus
161}
162#endif
163
164/**@}*/
165
166#endif
167/*  end of include file */
Note: See TracBrowser for help on using the repository browser.