[ECOS] eCos Kernel: ALLOC callbacks

NavEcos ecos@navosha.com
Thu Oct 24 22:33:00 GMT 2002


On Thursday 24 October 2002 08:24 pm, Jonathan Larmour wrote:

This was getting pretty long so:

[snip]

> Well, one could argue that the system and the user always use separate
> pools, the only exception being malloc, so malloc.cxx may be sufficient.
> In other words, are you sure you want to track the times the kernel uses
> memory pools (and remember they have a fixed size and are segregated from
> other dynamic allocations) for *any* reason, or only when you want to
> track those allocations that could overlap with a user's.

I want to track all allocations, or at least have the ability to in order to 
prove there are no memory leaks anywhere in the system.  Doing it for the 
system as well as the user level is equally easy, so I may as well cover all 
of them is my thinking.

I will submit a preliminary path pretty soon to the changes I make, and try to 
include CDL changes as well.

> >>>2)
> >>>
> >>>It appears that heaps are being created before cyg_user_start.  I want
> >>> to install the callbacks into the system before any heaps are created -
> >>> where should I install the callbacks?
> >>
> >>They are created by global constructors. "Simply" ( :-) ) create a 
> >> global constructor of higher priority than any constructor creating a
> >> heap.
> >
> > Ow - I think I got hooked on that catch.
> >
> > Can you provide pointers as to how to do this?  Is it ANSI C++ to do this
> > (i.e. portable across compilers) ?
>
> It's not ISO C++ or portable no. There's no way in ISO C++ to do this -
> global constructor initialization order is undefined. This is a G++
> extension. The info files document it, but the raw syntax is:
>
> Objtype obj __attribute__((init_priority(50000)));
>
> or some other number from 0 to 65535, the latter being the default init
> priority anyway. But the preferred way to do this is with a macro
> CYGBLD_ATTRIB_INIT_PRI. See infra/current/include/cyg_type.h. Search for
> the uses of this macro (grep -r) for usage examples. There's plenty
> around. Some code still uses the CYG_INIT_PRIORITY macro, but that's
> deprecated really.
>
> Jifl

OK - I'll look into doing that.

--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss



More information about the Ecos-discuss mailing list