Building, Heap partitions

Stefan Kalkowski stefan.kalkowski at ...1...
Thu Jan 28 12:05:13 CET 2010


Hi Peter,

when using 'destroy' you need to be aware of using the concrete class of the 
object you want to delete, otherwise dependend on the concrete allocator, it 
might not know how much memory needs to be freed.

regards
stefan

On Thursday, 28. January 2010 10:53:54 Norman Feske wrote:
> Hi Peter,
>
> > In trying to compile some code, i keep getting the following errors when
> > i try to instantiate a genode thread:
> >
> > undefined reference to `operator new[](unsigned int)'
> >
> > Can I not use "new" to allocate memory? If not, what is the proper way of
> > doing this via Genode?
>
> the default 'new' and 'delete' are not provided by the framework to
> raise awareness about memory allocations. The problem of the default
> new operator is that it leaves open the question to whom the allocated
> memory should be accounted. For example, a server that uses 'new' on
> behalf of client requests would make its own heap usage dependent on
> client behaviour and prone to resource-denial-of-service problems. In
> Genode, we promote the concept that such a server allocates such memory
> from a client-specific heap partition. More background information is
> provided here
>
>   http://genode.org/documentation/architecture/framework#Heap_partitioning
>
> Because the standard 'new' operator does not support the concept of
> heap partitions, we only provide a special 'new' operator that takes
> an 'Allocator' as argument. This way, the programmer must specify where
> to take the memory from. To allocate an object from the applications
> own heap, you can use the heap allocator provided by the process
> environment:
>
>   A *a = new (Genode::env()->heap()) A(constructor_argument)
>
> For destructing the object 'a', the allocator must be specified as well.
> Because this is not possible with the delete operator, we provide a
> 'destroy' template in 'include/base/allocator.h'. Instead of 'delete a'
> use:
>
>   destroy(Genode::env()->heap(), a)
>
> Despite of Genode not supporting standard 'new' and 'delete' by
> intention, it is relatively easy to create those operators out of the
> building blocks provided by Genode. For doing so, you may take a look at
> the following examples:
>
>   os/src/drivers/framebuffer/vesa/main.cc
>   demo/src/app/scout/genode/platform_genode.cc (line 78)
>
> Norman
>
> ---------------------------------------------------------------------------
>--- The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the
> business Choose flexible plans and management services without long-term
> contracts Personal 24x7 support from experience hosting pros just a phone
> call away. http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Genode-main mailing list
> Genode-main at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/genode-main



-- 
Stefan Kalkowski
Genode Labs Developer
http://genode-labs.com




More information about the users mailing list