source: rtems/cpukit/score/include/rtems/score/corespinlock.h @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 4.4 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 *  This routine initializes the spinlock based on the parameters passed.
114 *
115 *  @param[in] the_spinlock is the spinlock to initialize
116 *  @param[in] the_spinlock_attributes define the behavior of this instance
117 */
118void _CORE_spinlock_Initialize(
119  CORE_spinlock_Control       *the_spinlock,
120  CORE_spinlock_Attributes    *the_spinlock_attributes
121);
122
123/**
124 *  This routine wait for the spinlock to be released.  If the spinlock
125 *  is set to automatic and this is the appropriate thread, then it returns
126 *  immediately.  Otherwise, the calling thread is blocked until the spinlock
127 *  is released.
128 *
129 *  @param[in] the_spinlock is the spinlock to wait for
130 *  @param[in] wait is true if willing to wait
131 *  @param[in] timeout is the maximum number of ticks to spin (0 is forever)
132 *
133 * @return A status is returned which indicates the success or failure of
134 *         this operation.
135 */
136CORE_spinlock_Status _CORE_spinlock_Wait(
137  CORE_spinlock_Control  *the_spinlock,
138  bool                    wait,
139  Watchdog_Interval       timeout
140);
141
142/**
143 *  This routine manually releases the spinlock.  All of the threads waiting
144 *  for the spinlock will be readied.
145 *
146 *  @param[in] the_spinlock is the spinlock to surrender
147 */
148CORE_spinlock_Status _CORE_spinlock_Release(
149  CORE_spinlock_Control *the_spinlock
150);
151
152#ifndef __RTEMS_APPLICATION__
153#include <rtems/score/corespinlock.inl>
154#endif
155
156#ifdef __cplusplus
157}
158#endif
159
160/**@}*/
161
162#endif
163/*  end of include file */
Note: See TracBrowser for help on using the repository browser.