diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2004-10-15 21:05:07 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2004-10-15 21:05:07 +0000 |
commit | 626ace47dfdfd510ee8363381a97339f99303959 (patch) | |
tree | 20ef46bf72c4e67a8ba0c7b59254feb995ed35bc /cpukit/rtems/src/regionreturnsegment.c | |
parent | 2004-10-15 Gene Smith <gene.smith@seimens.com> (diff) | |
download | rtems-626ace47dfdfd510ee8363381a97339f99303959.tar.bz2 |
2004-10-15 Joel Sherrill <joel@OARcorp.com>
PR 692/rtems
* rtems/src/regiongetsegment.c, rtems/src/regionreturnsegment.c: The
Region Manager did not follow the proper protocol when blocking and
unblocking tasks waiting on buffers. This was a bug introduced with
the transition to an Allocation Mutex.
Diffstat (limited to 'cpukit/rtems/src/regionreturnsegment.c')
-rw-r--r-- | cpukit/rtems/src/regionreturnsegment.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/cpukit/rtems/src/regionreturnsegment.c b/cpukit/rtems/src/regionreturnsegment.c index 74517c0812..79d33b3828 100644 --- a/cpukit/rtems/src/regionreturnsegment.c +++ b/cpukit/rtems/src/regionreturnsegment.c @@ -94,6 +94,19 @@ 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 ); @@ -113,8 +126,8 @@ rtems_status_code rtems_region_return_segment( _Thread_queue_Extract( &the_region->Wait_queue, the_thread ); the_thread->Wait.return_code = RTEMS_SUCCESSFUL; } + _Thread_Enable_dispatch(); - _RTEMS_Unlock_allocator(); return RTEMS_SUCCESSFUL; } |