From: Jan Kiszka <jan.kiszka@domain.hid>
To: Stephan Zimmermann <s.zimmermann@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] RT Heap in Userspace
Date: Fri, 13 Jan 2006 00:14:45 +0100 [thread overview]
Message-ID: <43C6E2E5.4080900@domain.hid> (raw)
In-Reply-To: <200601121136.38271.s.zimmermann@domain.hid>
[-- Attachment #1: Type: text/plain, Size: 1414 bytes --]
Stephan Zimmermann wrote:
> Hello again,
> based on your information about memory allocation, I tried out the following:
>
> in main:
> // creating the Heap
> ret = rt_heap_create(&rt_heap,"Main-RT-Heap",rt_heapsize,H_FIFO);
>
> global:
> // overloaded operator new
> void* operator new(size_t size){
> void* newmem = NULL;
> int ret = rt_heap_alloc(&rt_heap,size,TM_INFINITE,&newmem);
> printf("new memory allocated: %i bytes, return %i\n",size,ret); fflush(NULL);
> return newmem;
> }
>
> This works fine, as long as I use a standard 'malloc' in my operator new. When
> executing the rt_... code, creating the heap returns 0 as expected. But
> trying to allocate some Memory insode of it using operator new fails with
> -EEINVAL.
>
> Reading the API-Doc more thoroughly, I saw a statement that H_SHARED is
> implicitly set, when a heap is created from Userspace (where my program
> executes).
> So, is ist possible to do what I try, or will I need to run in kernelspace for
> it? Maybe there is some 'trick' to do it?
>
If you do not depend on sharing the allocated memory between multiple
processes or kernel and user space, you may want to take a look at this
deterministic allocator library:
http://rtportal.upv.es/rtmalloc/allocators/tlsf/index.shtml
Should be straightforward to use it (at least it was with a previous
version I once tried).
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
prev parent reply other threads:[~2006-01-12 23:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-12 10:36 [Xenomai-help] RT Heap in Userspace Stephan Zimmermann
2006-01-12 15:49 ` Philippe Gerum
2006-01-12 23:14 ` Jan Kiszka [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43C6E2E5.4080900@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=s.zimmermann@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.