Doubtful code in rtems_region_return_segment().
Sergei Organov
osv at topconrd.ru
Fri Jan 21 17:35:43 UTC 2005
Hi,
The rtems_region_return_segment() routine looks like this (CVS trunc
version):
_RTEMS_Lock_allocator();
the_region = _Region_Get( id, &location );
[...]
status = _Region_Free_segment( the_region, segment );
[...]
/*
* 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();
[...]
1. The description of why we have to do this is unclear in the first
place, -- why unblocking of threads should be done with the allocator
unlocked? Is it strictly necessary, or is it just an optimization, or
what?
2. If this is indeed necessary, shouldn't _Thread_Disable_dispatch be
called before _RTEMS_Unlock_allocator to avoid races? Besides,
similar code in the rtems_region_get_segment does it in reverse order
indeed.
Thanks in advance for any clarification of the issue.
--
Sergei.
More information about the users
mailing list