memory overhead of rtems regions

Joel Sherrill joel.sherrill at OARcorp.com
Thu Mar 7 15:10:53 UTC 2013


Regions and message queues are completely independent.

Regions, like all RTEMS objects with IDs, have a control block
associated with them. The memory used for the region for
allocations is provided by you.  It can come from anywhere.
The maximum number of regions you can create is configured
by CONFIGURE_MAXIMUM_REGIONS.

Similarly, message queues have Ids and a similar maximum,
CONFIGURE_MAXIMUM_MESSAGE_QUEUES.  But the memory
for message buffers to hold pending messages comes from
the RTEMS Workspace and must be accounted for. This is what
a couple of configuration parameters are for.

CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(_messages, _size)
CONFIGURE_MESSAGE_BUFFER_MEMORY

CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE is used to calculate
the memory required for a SINGLE queue based on the message
size you use and the maximum pending. RTEMS has no idea what
those will be.

CONFIGURE_MESSAGE_BUFFER_MEMORY is the summation of
the memory used by all of the message queue buffers.

Alternatively, you can take the quick way out and use
CONFIGURE_UNLIMITED_OBJECTS and CONFIGURE_UNIFIED_WORK_AREAS
and not worry about this. [1]

By default, RTEMS wants you to configure hard limits in a precise
way. The thinking is that on many embedded systems, you should know
exactly what you are creating, how much memory you are using, etc..

The alternative is to put all the C Program Heap and RTEMS Workspace
together in a single pool and create/malloc until the system runs out of
memory.

Both are valid approaches to take. It depends on the goals of the
application and the control you want over resource allocation and the
effort you are willing to invest in configuring that.

For testing and playing around, using the unlimited/unified option is
a lot simpler.

--joel

[1] Unlimited only applies to threads, tasks, semaphores, etc. Objects
with Ids in the Classic and POSIX threads APIs. For example, it does not 
apply to
any file system or disk related configuration.


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


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20130307/ec130cd4/attachment.html>


More information about the users mailing list