Hi Venkatram,

I'm not sure what brk() has to do with my problem, but maybe I don't
understand exactly what it does...
What I want is a mechanism for implementing user-level stacks (for a sort of
fibers that I plan to implement) that grow automatically (so the next page
is mmap-ed into the process when needed). Can brk() help me?

Thanks,

- Andrei

On Tue, Apr 20, 2010 at 11:11 PM, Venkatram Tummala
<[email protected]>wrote:

>
>
> On Tue, Apr 20, 2010 at 2:47 AM, Andrei Matei <[email protected]>wrote:
>
>> Hi all,
>>
>> Does anybody know if/how I can obtain a virtual memory mapping that grows
>> automatically on memory accesses that fall in the page just below the
>> existing mapping, just like stacks do? On linux, stacks have this behavior,
>> both "default" processes' stacks and stacks allocated for pthreads. It even
>> works for stacks that I've allocated myself for pthreads (via mmap and
>> pthread_attr_setstack). But I cannot get it to work for a mapping that is
>> not used as a pthread stack; I get a SIGSEGV as soon as I step out of the
>> page I've mapped with mmap. I've found the MAP_GROWSDOWN flag for mmap that
>> is supposed to do this (at list some documentation implies it does it on
>> IA-64), but on my AMD64 machine it doesn't work. Other documentation seems
>> to suggest that MAP_GROWSDOWN is simply a hint to the kernel to try to
>> return a region that has free space below, which would mean that it can't be
>> combined with MAP_FIXED, which asks for a mapping at a fixed address, which
>> is what I want (and anyway, it doesn't seem to work even if I don't use
>> MAP_FIXED).
>> Any idea about this?
>>
>
> Just a curious question Andrei. Why can't you use brk() instead of mmap()
> if thats what you really want to achieve.
>
>>
>>
>> Thanks,
>>
>> - Andrei
>>
>
>

Reply via email to