summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/regionreturnsegment.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/rtems/src/regionreturnsegment.c')
-rw-r--r--cpukit/rtems/src/regionreturnsegment.c37
1 files changed, 2 insertions, 35 deletions
diff --git a/cpukit/rtems/src/regionreturnsegment.c b/cpukit/rtems/src/regionreturnsegment.c
index ad8037fe6b..dc080e5ed5 100644
--- a/cpukit/rtems/src/regionreturnsegment.c
+++ b/cpukit/rtems/src/regionreturnsegment.c
@@ -55,9 +55,7 @@ rtems_status_code rtems_region_return_segment(
)
{
register Region_Control *the_region;
- Thread_Control *the_thread;
Objects_Locations location;
- void **the_segment;
#ifdef RTEMS_REGION_FREE_SHRED_PATTERN
uint32_t size;
#endif
@@ -81,7 +79,7 @@ rtems_status_code rtems_region_return_segment(
#ifdef RTEMS_REGION_FREE_SHRED_PATTERN
if ( _Heap_Size_of_user_area( &the_region->Memory, segment, &size ) ) {
- memset(segment, (RTEMS_REGION_FREE_SHRED_PATTERN & 0xFF), size);
+ memset( segment, (RTEMS_REGION_FREE_SHRED_PATTERN & 0xFF), size );
} else {
_RTEMS_Unlock_allocator();
return RTEMS_INVALID_ADDRESS;
@@ -99,38 +97,7 @@ rtems_status_code rtems_region_return_segment(
the_region->number_of_used_blocks -= 1;
- /*
- * Switch from using the memory allocation mutex to using a
- * dispatching disabled critical section. We have to do this
- * because this thread may unblock one or more threads that were
- * waiting on memory.
- *
- * NOTE: The following loop is O(n) where n is the number of
- * threads whose memory request is satisfied.
- */
- _RTEMS_Unlock_allocator();
- _Thread_Disable_dispatch();
-
- for ( ; ; ) {
- the_thread = _Thread_queue_First( &the_region->Wait_queue );
-
- if ( the_thread == NULL )
- break;
-
- the_segment = (void **) _Region_Allocate_segment(
- the_region,
- the_thread->Wait.count
- );
-
- if ( the_segment == NULL )
- break;
-
- *(void **)the_thread->Wait.return_argument = the_segment;
- the_region->number_of_used_blocks += 1;
- _Thread_queue_Extract( &the_region->Wait_queue, the_thread );
- the_thread->Wait.return_code = RTEMS_SUCCESSFUL;
- }
- _Thread_Enable_dispatch();
+ _Region_Process_queue(the_region); /* unlocks allocator internally */
return RTEMS_SUCCESSFUL;
}