source: rtems/cpukit/include/rtems/score/coresemimpl.h @ 878487b0

5
Last change on this file since 878487b0 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: 5.6 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines Associated with the SuperCore Semaphore
5 *
6 * This include file contains all of the inlined routines associated
7 * with the SuperCore semaphore.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2006.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _RTEMS_SCORE_CORESEMIMPL_H
20#define _RTEMS_SCORE_CORESEMIMPL_H
21
22#include <rtems/score/coresem.h>
23#include <rtems/score/objectimpl.h>
24#include <rtems/score/threaddispatch.h>
25#include <rtems/score/threadimpl.h>
26#include <rtems/score/threadqimpl.h>
27#include <rtems/score/statesimpl.h>
28#include <rtems/score/status.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/**
35 * @addtogroup ScoreSemaphore
36 */
37/**@{**/
38
39/**
40 *  @brief Initialize the semaphore based on the parameters passed.
41 *
42 *  This package is the implementation of the CORE Semaphore Handler.
43 *  This core object utilizes standard Dijkstra counting semaphores to provide
44 *  synchronization and mutual exclusion capabilities.
45 *
46 *  This routine initializes the semaphore based on the parameters passed.
47 *
48 *  @param[in] the_semaphore is the semaphore to initialize
49 *  @param[in] initial_value is the initial count of the semaphore
50 */
51void _CORE_semaphore_Initialize(
52  CORE_semaphore_Control *the_semaphore,
53  uint32_t                initial_value
54);
55
56RTEMS_INLINE_ROUTINE void _CORE_semaphore_Acquire_critical(
57  CORE_semaphore_Control *the_semaphore,
58  Thread_queue_Context   *queue_context
59)
60{
61  _Thread_queue_Acquire_critical( &the_semaphore->Wait_queue, queue_context );
62}
63
64RTEMS_INLINE_ROUTINE void _CORE_semaphore_Release(
65  CORE_semaphore_Control *the_semaphore,
66  Thread_queue_Context   *queue_context
67)
68{
69  _Thread_queue_Release( &the_semaphore->Wait_queue, queue_context );
70}
71
72RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy(
73  CORE_semaphore_Control        *the_semaphore,
74  const Thread_queue_Operations *operations,
75  Thread_queue_Context          *queue_context
76)
77{
78  _Thread_queue_Flush_critical(
79    &the_semaphore->Wait_queue.Queue,
80    operations,
81    _Thread_queue_Flush_status_object_was_deleted,
82    queue_context
83  );
84  _Thread_queue_Destroy( &the_semaphore->Wait_queue );
85}
86
87/**
88 *  @brief Surrender a unit to a semaphore.
89 *
90 *  This routine frees a unit to the semaphore.  If a task was blocked waiting
91 *  for a unit from this semaphore, then that task will be readied and the unit
92 *  given to that task.  Otherwise, the unit will be returned to the semaphore.
93 *
94 *  @param[in] the_semaphore is the semaphore to surrender
95 *  @param[in] operations The thread queue operations.
96 *  @param[in] queue_context is a temporary variable used to contain the ISR
97 *        disable level cookie
98 *
99 *  @retval an indication of whether the routine succeeded or failed
100 */
101RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Surrender(
102  CORE_semaphore_Control        *the_semaphore,
103  const Thread_queue_Operations *operations,
104  uint32_t                       maximum_count,
105  Thread_queue_Context          *queue_context
106)
107{
108  Thread_Control *the_thread;
109  Status_Control  status;
110
111  status = STATUS_SUCCESSFUL;
112
113  _CORE_semaphore_Acquire_critical( the_semaphore, queue_context );
114
115  the_thread = _Thread_queue_First_locked(
116    &the_semaphore->Wait_queue,
117    operations
118  );
119  if ( the_thread != NULL ) {
120    _Thread_queue_Extract_critical(
121      &the_semaphore->Wait_queue.Queue,
122      operations,
123      the_thread,
124      queue_context
125    );
126  } else {
127    if ( the_semaphore->count < maximum_count )
128      the_semaphore->count += 1;
129    else
130      status = STATUS_MAXIMUM_COUNT_EXCEEDED;
131
132    _CORE_semaphore_Release( the_semaphore, queue_context );
133  }
134
135  return status;
136}
137
138/**
139 * This routine returns the current count associated with the semaphore.
140 *
141 * @param[in] the_semaphore is the semaphore to obtain the count of
142 *
143 * @return the current count of this semaphore
144 */
145RTEMS_INLINE_ROUTINE uint32_t  _CORE_semaphore_Get_count(
146  const CORE_semaphore_Control *the_semaphore
147)
148{
149  return the_semaphore->count;
150}
151
152/**
153 * This routine attempts to receive a unit from the_semaphore.
154 * If a unit is available or if the wait flag is false, then the routine
155 * returns.  Otherwise, the calling task is blocked until a unit becomes
156 * available.
157 *
158 * @param[in] the_semaphore is the semaphore to obtain
159 * @param[in] operations The thread queue operations.
160 * @param[in] executing The currently executing thread.
161 * @param[in] wait is true if the thread is willing to wait
162 * @param[in] queue_context is a temporary variable used to contain the ISR
163 *        disable level cookie
164 */
165RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize(
166  CORE_semaphore_Control        *the_semaphore,
167  const Thread_queue_Operations *operations,
168  Thread_Control                *executing,
169  bool                           wait,
170  Thread_queue_Context          *queue_context
171)
172{
173  _Assert( _ISR_Get_level() != 0 );
174
175  _CORE_semaphore_Acquire_critical( the_semaphore, queue_context );
176  if ( the_semaphore->count != 0 ) {
177    the_semaphore->count -= 1;
178    _CORE_semaphore_Release( the_semaphore, queue_context );
179    return STATUS_SUCCESSFUL;
180  }
181
182  if ( !wait ) {
183    _CORE_semaphore_Release( the_semaphore, queue_context );
184    return STATUS_UNSATISFIED;
185  }
186
187  _Thread_queue_Context_set_thread_state(
188    queue_context,
189    STATES_WAITING_FOR_SEMAPHORE
190  );
191  _Thread_queue_Enqueue(
192    &the_semaphore->Wait_queue.Queue,
193    operations,
194    executing,
195    queue_context
196  );
197  return _Thread_Wait_get_status( executing );
198}
199
200/** @} */
201
202#ifdef __cplusplus
203}
204#endif
205
206#endif
207/* end of include file */
Note: See TracBrowser for help on using the repository browser.