source: rtems/cpukit/include/rtems/score/smplockticket.h @ 21275b58

5
Last change on this file since 21275b58 was 2afb22b, checked in by Chris Johns <chrisj@…>, on 12/23/17 at 07:18:56

Remove make preinstall

A speciality of the RTEMS build system was the make preinstall step. It
copied header files from arbitrary locations into the build tree. The
header files were included via the -Bsome/build/tree/path GCC command
line option.

This has at least seven problems:

  • The make preinstall step itself needs time and disk space.
  • Errors in header files show up in the build tree copy. This makes it hard for editors to open the right file to fix the error.
  • There is no clear relationship between source and build tree header files. This makes an audit of the build process difficult.
  • The visibility of all header files in the build tree makes it difficult to enforce API barriers. For example it is discouraged to use BSP-specifics in the cpukit.
  • An introduction of a new build system is difficult.
  • Include paths specified by the -B option are system headers. This may suppress warnings.
  • The parallel build had sporadic failures on some hosts.

This patch removes the make preinstall step. All installed header
files are moved to dedicated include directories in the source tree.
Let @RTEMS_CPU@ be the target architecture, e.g. arm, powerpc, sparc,
etc. Let @RTEMS_BSP_FAMILIY@ be a BSP family base directory, e.g.
erc32, imx, qoriq, etc.

The new cpukit include directories are:

  • cpukit/include
  • cpukit/score/cpu/@RTEMS_CPU@/include
  • cpukit/libnetworking

The new BSP include directories are:

  • bsps/include
  • bsps/@RTEMS_CPU@/include
  • bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILIY@/include

There are build tree include directories for generated files.

The include directory order favours the most general header file, e.g.
it is not possible to override general header files via the include path
order.

The "bootstrap -p" option was removed. The new "bootstrap -H" option
should be used to regenerate the "headers.am" files.

Update #3254.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreSMPLock
5 *
6 * @brief SMP Lock API
7 */
8
9/*
10 * Copyright (c) 2013, 2016 embedded brains GmbH
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.org/license/LICENSE.
15 */
16
17#ifndef _RTEMS_SCORE_SMPLOCKTICKET_H
18#define _RTEMS_SCORE_SMPLOCKTICKET_H
19
20#include <rtems/score/cpuopts.h>
21
22#if defined(RTEMS_SMP)
23
24#include <rtems/score/atomic.h>
25#include <rtems/score/smplockstats.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif /* __cplusplus */
30
31/**
32 * @addtogroup ScoreSMPLock
33 *
34 * @{
35 */
36
37/**
38 * @brief SMP ticket lock control.
39 */
40typedef struct {
41  Atomic_Uint next_ticket;
42  Atomic_Uint now_serving;
43} SMP_ticket_lock_Control;
44
45/**
46 * @brief SMP ticket lock control initializer for static initialization.
47 */
48#define SMP_TICKET_LOCK_INITIALIZER \
49  { \
50    ATOMIC_INITIALIZER_UINT( 0U ), \
51    ATOMIC_INITIALIZER_UINT( 0U ) \
52  }
53
54/**
55 * @brief Initializes an SMP ticket lock.
56 *
57 * Concurrent initialization leads to unpredictable results.
58 *
59 * @param[in] lock The SMP ticket lock control.
60 */
61static inline void _SMP_ticket_lock_Initialize(
62  SMP_ticket_lock_Control *lock
63)
64{
65  _Atomic_Init_uint( &lock->next_ticket, 0U );
66  _Atomic_Init_uint( &lock->now_serving, 0U );
67}
68
69/**
70 * @brief Destroys an SMP ticket lock.
71 *
72 * Concurrent destruction leads to unpredictable results.
73 *
74 * @param[in] lock The SMP ticket lock control.
75 */
76static inline void _SMP_ticket_lock_Destroy( SMP_ticket_lock_Control *lock )
77{
78  (void) lock;
79}
80
81static inline void _SMP_ticket_lock_Do_acquire(
82  SMP_ticket_lock_Control *lock
83#if defined(RTEMS_PROFILING)
84  ,
85  SMP_lock_Stats          *stats,
86  SMP_lock_Stats_context  *stats_context
87#endif
88)
89{
90  unsigned int                   my_ticket;
91  unsigned int                   now_serving;
92#if defined(RTEMS_PROFILING)
93  unsigned int                   initial_queue_length;
94  SMP_lock_Stats_acquire_context acquire_context;
95
96  _SMP_lock_Stats_acquire_begin( &acquire_context );
97#endif
98
99  my_ticket =
100    _Atomic_Fetch_add_uint( &lock->next_ticket, 1U, ATOMIC_ORDER_RELAXED );
101
102#if defined(RTEMS_PROFILING)
103  now_serving =
104    _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_ACQUIRE );
105  initial_queue_length = my_ticket - now_serving;
106
107  if ( initial_queue_length > 0 ) {
108#endif
109
110    do {
111      now_serving =
112        _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_ACQUIRE );
113    } while ( now_serving != my_ticket );
114
115#if defined(RTEMS_PROFILING)
116  }
117
118  _SMP_lock_Stats_acquire_end(
119    &acquire_context,
120    stats,
121    stats_context,
122    initial_queue_length
123  );
124#endif
125}
126
127/**
128 * @brief Acquires an SMP ticket lock.
129 *
130 * This function will not disable interrupts.  The caller must ensure that the
131 * current thread of execution is not interrupted indefinite once it obtained
132 * the SMP ticket lock.
133 *
134 * @param[in] lock The SMP ticket lock control.
135 * @param[in] stats The SMP lock statistics.
136 * @param[out] stats_context The SMP lock statistics context.
137 */
138#if defined(RTEMS_PROFILING)
139  #define _SMP_ticket_lock_Acquire( lock, stats, stats_context ) \
140    _SMP_ticket_lock_Do_acquire( lock, stats, stats_context )
141#else
142  #define _SMP_ticket_lock_Acquire( lock, stats, stats_context ) \
143    _SMP_ticket_lock_Do_acquire( lock )
144#endif
145
146static inline void _SMP_ticket_lock_Do_release(
147  SMP_ticket_lock_Control *lock
148#if defined(RTEMS_PROFILING)
149  ,
150  const SMP_lock_Stats_context *stats_context
151#endif
152)
153{
154  unsigned int current_ticket =
155    _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_RELAXED );
156  unsigned int next_ticket = current_ticket + 1U;
157
158#if defined(RTEMS_PROFILING)
159  _SMP_lock_Stats_release_update( stats_context );
160#endif
161
162  _Atomic_Store_uint( &lock->now_serving, next_ticket, ATOMIC_ORDER_RELEASE );
163}
164
165/**
166 * @brief Releases an SMP ticket lock.
167 *
168 * @param[in] lock The SMP ticket lock control.
169 * @param[in] stats_context The SMP lock statistics context.
170 */
171#if defined(RTEMS_PROFILING)
172  #define _SMP_ticket_lock_Release( lock, stats_context ) \
173    _SMP_ticket_lock_Do_release( lock, stats_context )
174#else
175  #define _SMP_ticket_lock_Release( lock, stats_context ) \
176    _SMP_ticket_lock_Do_release( lock )
177#endif
178
179/**@}*/
180
181#ifdef __cplusplus
182}
183#endif /* __cplusplus */
184
185#endif /* RTEMS_SMP */
186
187#endif /* _RTEMS_SCORE_SMPLOCKTICKET_H */
Note: See TracBrowser for help on using the repository browser.