more cache manager issues

Till Straumann strauman at SLAC.Stanford.EDU
Tue Oct 31 18:23:42 UTC 2000


Eric Norum wrote:

> Till Straumann wrote:
> >
> > Browsing through the cache manager implementation of
> > `rtems-ss-20000929' caused me having some more questions
> > / suggestions:
> >
> >  - cache_aligned_malloc() (currently not called by any piece of code)
> > must not
> >      be used. Calling `free' on memory allocated by
> > cache_aligned_malloc() results
> >      in heap corruption.
> >
>
> Here's my solution to the problem.  Note that a block of memory
> allocated by rtems_cache_aligned_malloc can only be freed by calling
> rtems_cache_aligned_free and that rtems_cache_aligned_free can be used
> only to free a block of memory allocated by rtems_cache_aligned_malloc.

An alternative to this approach would be letting
rtems_cache_aligned_malloc()
using its own heap with a bigger (cache aligned) granularity.

One global `free(arg)' function could then determine the heap
corresponding to the argument
by comparing the argument pointer to the standard heap / aligned heap
starting and end addresses.

Even more elegant would of course be an object oriented approach with a
virtual `free' member
function (or a field in the block header holding the information about
which version of `free' must
be used for that specific block of memory).

IMHO, the need to call a `special' deallocator function is very error
prone.

-- Till.




More information about the users mailing list