RES: Problem using Region Manager with very small segments

Fabrício de Novaes Kucinskis fabricio at
Thu Jul 3 16:28:30 UTC 2008

Thanks, Joel, I'll create a small example that will reproduce the error, and
send it to the list. Meanwhile, I have more information about the
RTEMS_INVALID_SIZE error that may help understanding it.

I looked inside rtems_region_get_segment, and noticed that the error happens
because the value of the_region->maximum_segment_size suddenly turns to
zero! I don't think this value should change once the region is created, so
maybe the memory area to where "*the_region" points is being overwritten.

More info: it appears that the error happens when the caller task is
interrupted by a UART ISR. Since the interrupt stack uses memory from the
RTEMS workspace area, is it possible that the interruption is triggering
such overwrite? I don't think so, since the ERC32 reserves 16KB to the
interrupt stack, which should be much more than enough - but I don't see
other reasons for the error.



-----Mensagem original-----
De: Joel Sherrill [mailto:joel.sherrill at] 
Enviada em: quinta-feira, 3 de julho de 2008 09:46
Para: Fabrício de Novaes Kucinskis
Cc: 'RTEMS - Mailing List'
Assunto: Re: Problem using Region Manager with very small segments

Please send me some (simple) code that reproduces this and I
will look into it.


Fabrício de Novaes Kucinskis wrote:
> Hello all,
> I have an ERC32 application, in which I create a Region with length = 512
> bytes and page_size = 8 bytes.
> The RTEMS User Manual says that the page_size shall be a multiple of four
> greater or equal four, but if I try to create a region with page_size = 4
> got a "RTEMS_INVALID_PAGE_SIZE" error. Using page_size = 8 there is no
> but, when I ask for a segment of, say, 5 bytes, I got a 12 byte-segment,
> not a 8 byte-segment, as would be expected.
> Furthermore, I'm having a weird problem, and that's the main reason for
> call for help: normally I ask for segments of 2 to 16 bytes. The
> seems to work properly, but sometimes I got a RTEMS_INVALID_SIZE error (do
> not confuse with RTEMS_UNSATISFIED).
> The strange thing here is that I got this error when asking for a
> segment, when only two segments of no more than 24 bytes are allocated.
> RTEMS_INVALID_SIZE should occur only when the size of the segment is zero
> greater than the maximum segment possible, which is not the case.
> I checked, and my application doesn't write outside the segments
> so I don't think the region is corrupted. Could be then some problem with
> the segment's overhead? The manual states that there is an overhead for
> segment, but it lacks information about the size of such overhead. I know
> is not possible to calculate the number of bytes available in a region,
> what is the overhead per segment?
> Any help or additional information will be greatly appreciated.
> Thanks in advance and best regards,
> Fabrício de Novaes Kucinskis - DEA / INPE
> -----------------------------------------------
> Onboard Data Handling Group - SUBORD
> Aerospace Electronics Division
> Brazilian National Institute for Space Research
> _______________________________________________
> rtems-users mailing list
> rtems-users at

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

More information about the users mailing list