diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2004-10-15 20:06:35 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2004-10-15 20:06:35 +0000 |
commit | 8d55b1f03c22a2b53f90682736d808f1397c02fd (patch) | |
tree | d333155a279d418af71cd88f4abe9771c621ebd0 /cpukit | |
parent | 2004-10-15 Gene Smith <gene.smith@seimens.com> (diff) | |
download | rtems-8d55b1f03c22a2b53f90682736d808f1397c02fd.tar.bz2 |
2004-10-15 Joel Sherrill <joel@OARcorp.com>
PR 692/rtems
* src/regiongetsegment.c, 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')
-rw-r--r-- | cpukit/rtems/ChangeLog | 8 | ||||
-rw-r--r-- | cpukit/rtems/src/regiongetsegment.c | 11 | ||||
-rw-r--r-- | cpukit/rtems/src/regionreturnsegment.c | 15 |
3 files changed, 32 insertions, 2 deletions
diff --git a/cpukit/rtems/ChangeLog b/cpukit/rtems/ChangeLog index 2f84ccdee6..a241137d8b 100644 --- a/cpukit/rtems/ChangeLog +++ b/cpukit/rtems/ChangeLog @@ -1,3 +1,11 @@ +2004-10-15 Joel Sherrill <joel@OARcorp.com> + + PR 692/rtems + * src/regiongetsegment.c, 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. + 2004-07-24 Mick Davis <mickd@microsol.iinet.net.au> PR 641/rtems diff --git a/cpukit/rtems/src/regiongetsegment.c b/cpukit/rtems/src/regiongetsegment.c index b80fd911a7..dc98b57375 100644 --- a/cpukit/rtems/src/regiongetsegment.c +++ b/cpukit/rtems/src/regiongetsegment.c @@ -98,6 +98,14 @@ rtems_status_code rtems_region_get_segment( return RTEMS_UNSATISFIED; } + /* + * Switch from using the memory allocation mutex to using a + * dispatching disabled critical section. We have to do this + * because this thread is going to block. + */ + _Thread_Disable_dispatch(); + _RTEMS_Unlock_allocator(); + executing->Wait.queue = &the_region->Wait_queue; executing->Wait.id = id; executing->Wait.count = size; @@ -107,7 +115,8 @@ rtems_status_code rtems_region_get_segment( _Thread_queue_Enqueue( &the_region->Wait_queue, timeout ); - _RTEMS_Unlock_allocator(); + _Thread_Enable_dispatch(); + return (rtems_status_code) executing->Wait.return_code; } diff --git a/cpukit/rtems/src/regionreturnsegment.c b/cpukit/rtems/src/regionreturnsegment.c index bc1ecafb9b..c9c134e02b 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; } |