Boost logo

Boost :

Subject: Re: [boost] [context] Why does boost::ctx::minimum_stacksize() on Windows return 65536
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2012-09-02 13:08:02


Am 02.09.2012 02:01, schrieb Hartmut Kaiser:
> Hey all,
>
> Why is the minimally possible stack size in Boost.Context on Windows set to
> be 64k? This seems to be way too high for applications where only a minimal
> amount of stack is required. I assume, that since Boost.Context allocates
> the stack using VirtualAlloc the minimum possible value should be equal to
> the page size (see
> http://msdn.microsoft.com/en-us/library/windows/desktop/aa366887(v=vs.85).as
> px).
>
boost.context provides a default implementation of a stack-allocator
(class stack_allocator) which appends each stack a guard page (guard
pages will not be mapped to physical pages - you don't was memory).
Function VirtualProtect() is used to set the 'guard' flag on the page
and requires VirtualAlloc().

I decided to provide the same stacksize as Win32 Fiber API does - which
is system's allocation granularity (64kB; using GetSystemInfo() ).

If context's default stack allocation does not satisfy your requirements
you can easily implement and use your own stack allocator together with
make_fcontext()/jump_fcontext().

regards,
Oliver


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk