<p dir="ltr">Gedare,</p>
<p dir="ltr">Thanks for the advice, for this particular region that's the optimal size, I've done a bit of experimentation and you can find an optimal size for most allocations.<br>
</p>
<div class="gmail_quote">On 7 Mar 2013 14:38, "Gedare Bloom" <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Looking closer, your allocations are multiples of 40. You should set<br>
the page_size to 40 in your region create.<br>
<br>
On Thu, Mar 7, 2013 at 9:37 AM, Gedare Bloom <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br>
> You're right. The error return does indicate that memory ran out. It's<br>
> not clear if the memory that ran out is heap or workspace.<br>
><br>
> You set a page_size of 128, and then make allocations in multiples of<br>
> 10. I think the segments that get returned are allocated as multiples<br>
> of the page_size. So there will be some fragmentation issues. E.g. a<br>
> request for a segment of size 400 will return a 512 size segment,<br>
> wasting 112 bytes. This is stated in the C User Manual section about<br>
> Regions [1]. This fragmentation is probably causing the problem.<br>
><br>
> -Gedare<br>
><br>
> [1] <a href="http://rtems.org/onlinedocs/doc-current/share/rtems/html/c_user/Region-Manager-Region-Manager-Definitions.html#Region-Manager-Region-Manager-Definitions" target="_blank">http://rtems.org/onlinedocs/doc-current/share/rtems/html/c_user/Region-Manager-Region-Manager-Definitions.html#Region-Manager-Region-Manager-Definitions</a><br>

><br>
> On Thu, Mar 7, 2013 at 9:21 AM, Matthew J Fletcher <<a href="mailto:amimjf@gmail.com">amimjf@gmail.com</a>> wrote:<br>
>> Hi,<br>
>><br>
>> Its 20, but I believe that would return RTEMS_TO_MANY, if that was not<br>
>> enough.<br>
>><br>
>> On 7 Mar 2013 14:09, "Gedare Bloom" <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br>
>>><br>
>>> Check how many message queues your application has configured.<br>
>>><br>
>>> #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES    ?<br>
>>><br>
>>> On Thu, Mar 7, 2013 at 7:05 AM, Matthew J Fletcher <<a href="mailto:amimjf@gmail.com">amimjf@gmail.com</a>><br>
>>> wrote:<br>
>>> > Hi,<br>
>>> ><br>
>>> > Reading the documentation for rtems regions is a bit vague about the<br>
>>> > overhead of the lists that behind the scenes manage the blocks. Its<br>
>>> > quite<br>
>>> > possible i am not fully understanding the operation. I have a call<br>
>>> > sequence<br>
>>> > as follows.<br>
>>> ><br>
>>> > rtems_region_create( length = 19800, page_size = 128 )<br>
>>> >   rtems_region_get_segment( size = 160 )<br>
>>> >     rtems_message_queue_create ( count = 160, max_size =2 )<br>
>>> >   rtems_region_get_segment( size = 400 )<br>
>>> >     rtems_message_queue_create ( count = 400, max_size =2 )<br>
>>> >   rtems_region_get_segment( size = 1600 )<br>
>>> >     rtems_message_queue_create ( count = 1600, max_size =2 )<br>
>>> >   rtems_region_get_segment( size = 40 )<br>
>>> >     rtems_message_queue_create ( count = 40, max_size =2 )<br>
>>> >   rtems_region_get_segment( size = 4000 )<br>
>>> >     rtems_message_queue_create ( count = 4000, max_size =2 )<br>
>>> >   rtems_region_get_segment( size = 40 )<br>
>>> >     rtems_message_queue_create ( count = 40, max_size =2 )<br>
>>> >   rtems_region_get_segment( size = 40 )<br>
>>> >     rtems_message_queue_create ( count = 40, max_size =2 )<br>
>>> >   rtems_region_get_segment( size = 40 )<br>
>>> >     rtems_message_queue_create ( count = 40, max_size =2 )<br>
>>> >   rtems_region_get_segment( size = 40 )<br>
>>> >     rtems_message_queue_create ( count = 40, max_size =2 )<br>
>>> >   rtems_region_get_segment( size = 120 )<br>
>>> >     rtems_message_queue_create ( count = 120, max_size =2 )<br>
>>> >   rtems_region_get_segment( size = 400 )<br>
>>> >     rtems_message_queue_create ( count = 400, max_size =2 )<br>
>>> >   rtems_region_get_segment( size = 400 )<br>
>>> >     rtems_message_queue_create ( count = 400, max_size =2 )<br>
>>> >   rtems_region_get_segment( size = 2000 ) // total size upto here 7320<br>
>>> >     rtems_message_queue_create ( count = 2000, max_size =2 )<br>
>>> >     // returns RTEMS_UNSATISFIED - unable to allocate message buffers<br>
>>> > here<br>
>>> ><br>
>>> > I dont fully understand why RTEMS_UNSATISFIED is being returned from the<br>
>>> > queue_create(), is there really a 50%+ overhead in managing 128 byte<br>
>>> > pages ?<br>
>>> > out of a 19800 length.<br>
>>> ><br>
>>> > I am presuming that the RTEMS_UNSATISFIED is because of the region size,<br>
>>> > but<br>
>>> > i could be wrong about that.<br>
>>> ><br>
>>> ><br>
>>> > regards<br>
>>> > ---<br>
>>> > Matthew J Fletcher<br>
>>> ><br>
>>> ><br>
>>> > _______________________________________________<br>
>>> > rtems-users mailing list<br>
>>> > <a href="mailto:rtems-users@rtems.org">rtems-users@rtems.org</a><br>
>>> > <a href="http://www.rtems.org/mailman/listinfo/rtems-users" target="_blank">http://www.rtems.org/mailman/listinfo/rtems-users</a><br>
>>> ><br>
</blockquote></div>