source: rtems/cpukit/rtems/include/rtems/rtems/regionimpl.h @ 02c4c441

4.115
Last change on this file since 02c4c441 was 02c4c441, checked in by Sebastian Huber <sebastian.huber@…>, on 04/23/15 at 08:01:22

score: Add Thread_queue_Control::Lock

Move the complete thread queue enqueue procedure into
_Thread_queue_Enqueue_critical(). It is possible to use the thread
queue lock to protect state of the object embedding the thread queue.
This enables per object fine grained locking in the future.

Delete _Thread_queue_Enter_critical_section().

Update #2273.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicRegionImpl
5 *
6 * @brief Classic Region Manager Implementation
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.org/license/LICENSE.
15 */
16
17#ifndef _RTEMS_RTEMS_REGIONIMPL_H
18#define _RTEMS_RTEMS_REGIONIMPL_H
19
20#include <rtems/rtems/region.h>
21#include <rtems/score/heapimpl.h>
22#include <rtems/score/objectimpl.h>
23#include <rtems/score/threadqimpl.h>
24#include <rtems/debug.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/**
31 * @defgroup ClassicRegionImpl Classic Region Manager Implementation
32 *
33 * @ingroup ClassicRegion
34 *
35 * @{
36 */
37
38/**
39 *  @brief Instantiate RTEMS Region Data
40 *
41 *  Region Manager -- Instantiate Data
42 *
43 *  This constant is defined to extern most of the time when using
44 *  this header file.  However by defining it to nothing, the data
45 *  declared in this header file can be instantiated.  This is done
46 *  in a single per manager file.
47 */
48#ifndef RTEMS_REGION_EXTERN
49#define RTEMS_REGION_EXTERN extern
50#endif
51
52/**
53 *  The following defines the information control block used to
54 *  manage this class of objects.
55 */
56RTEMS_REGION_EXTERN Objects_Information _Region_Information;
57
58/**
59 *  @brief _Region_Manager_initialization
60 *
61 *  Region Manager
62 *
63 *  This routine performs the initialization necessary for this manager.
64 */
65void _Region_Manager_initialization(void);
66
67/**
68 *  @brief Region_Allocate
69 *
70 *  This function allocates a region control block from
71 *  the inactive chain of free region control blocks.
72 */
73RTEMS_INLINE_ROUTINE Region_Control *_Region_Allocate( void )
74{
75  return (Region_Control *) _Objects_Allocate( &_Region_Information );
76}
77
78/**
79 *  @brief Region_Free
80 *
81 *  This routine frees a region control block to the
82 *  inactive chain of free region control blocks.
83 */
84RTEMS_INLINE_ROUTINE void _Region_Free (
85  Region_Control *the_region
86)
87{
88  _Thread_queue_Destroy( &the_region->Wait_queue );
89  _Objects_Free( &_Region_Information, &the_region->Object );
90}
91
92/**
93 *  @brief Region_Get
94 *
95 *  This function maps region IDs to region control blocks.
96 *  If ID corresponds to a local region, then it returns
97 *  the_region control pointer which maps to ID and location
98 *  is set to OBJECTS_LOCAL.  Otherwise, location is set
99 *  to OBJECTS_ERROR and the_region is undefined.
100 */
101RTEMS_INLINE_ROUTINE Region_Control *_Region_Get (
102  Objects_Id         id,
103  Objects_Locations *location
104)
105{
106  return (Region_Control *)
107    _Objects_Get_no_protection( &_Region_Information, id, location );
108}
109
110/**
111 *  @brief Region_Allocate_segment
112 *
113 *  This function attempts to allocate a segment from the_region.
114 *  If successful, it returns the address of the allocated segment.
115 *  Otherwise, it returns NULL.
116 */
117RTEMS_INLINE_ROUTINE void *_Region_Allocate_segment (
118  Region_Control *the_region,
119  uintptr_t       size
120)
121{
122  return _Heap_Allocate( &the_region->Memory, size );
123}
124
125/**
126 *  @brief Region_Free_segment
127 *
128 *  This function frees the_segment to the_region.
129 */
130RTEMS_INLINE_ROUTINE bool _Region_Free_segment (
131  Region_Control *the_region,
132  void           *the_segment
133)
134{
135  return _Heap_Free( &the_region->Memory, the_segment );
136}
137
138/**
139 *  @brief Process Region Queue
140 *
141 *  This is a helper routine which is invoked any time memory is
142 *  freed.  It looks at the set of waiting tasks and attempts to
143 *  satisfy all outstanding requests.
144 *
145 *  @param[in] the_region is the the region
146 */
147extern void _Region_Process_queue(Region_Control *the_region);
148
149/**
150 *  @brief _Region_Debug_Walk
151 *
152 *  This routine is invoked to verify the integrity of a heap associated
153 *  with the_region.
154 */
155#ifdef RTEMS_DEBUG
156
157#define _Region_Debug_Walk( _the_region, _source ) \
158  do { \
159    if ( rtems_debug_is_enabled( RTEMS_DEBUG_REGION ) ) \
160      _Heap_Walk( &(_the_region)->Memory, _source, false ); \
161  } while ( 0 )
162
163#else
164
165#define _Region_Debug_Walk( _the_region, _source )
166
167#endif
168
169/**@}*/
170
171#ifdef __cplusplus
172}
173#endif
174
175#if defined(RTEMS_MULTIPROCESSING)
176#include <rtems/rtems/regionmp.h>
177#endif
178
179#endif
180/* end of include file */
Note: See TracBrowser for help on using the repository browser.