Thin Lock Implementation

Steven Schveighoffer schveiguy at yahoo.com
Tue Aug 19 09:01:32 PDT 2008


"Jb" wrote
>
> "Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message 
> news:g8emvj$1cu5$1 at digitalmars.com...
>> "Sascha Katzner" wrote
>>> Steven Schveighoffer wrote:
>>>> On a 32-bit system, the amount of addressable memory space and the
>>>> stack size are the factors that limit the number of threads.  For
>>>> example, if addressable space is 2GB, and each thread has a 1MB
>>>> stack, that's 2000 threads max (this is the typical situation for
>>>> Windows).
>>>
>>> Not exactly right, since the stack is organized in 4kb pages and these
>>> pages are not initialized until they are first used they usually require
>>> a lot less than 1mb.
>>
>> Hm... I read the limit above online 
>> (http://blogs.msdn.com/oldnewthing/archive/2005/07/29/444912.aspx).  I 
>> think maybe the pages aren't initialized, but doesn't the system have to 
>> reserve them because it has to guarantee a 1MB stack for each?  Or maybe 
>> that guy is completely wrong, or the concept has been fixed :)
>
> Read the whole page ;-)
>
> The 1MB is just the default stack size if you pass a value of zero to the 
> CreateThread function, and usualy most linkers / librarys whatever do 
> that.
>
> You can override this by specifying the stack size. And as he said he 
> could then create 13000 rather than 2000 threads.
>
> But the actualy mimimum size is 64k, as that is the granularity of the 
> windows allocator. You can check by calling getSystemInfo, and examining 
> the allocationGranularity, but I've never seen it return anything other 
> than 64k.


Read my whole post :)

"this is the typical situation for Windows"

i.e. the default.

-Steve 





More information about the Digitalmars-d mailing list