Article View: borland.public.cppbuilder.nativeapi
Article #17540Re: Tweaking threads
From: Chris Hill
Date: Fri, 14 Mar 2003 04:14
Date: Fri, 14 Mar 2003 04:14
28 lines
2233 bytes
2233 bytes
On Thu, 13 Mar 2003 02:27:02 -0600, "Ted Tripp" <ttripp@skypoint.com> wrote: >Another question, I vaguely recall reading that threads are initialized with >a certain (default?) amount of memory. I seem to recall something like >1MB--maybe this was a nonwindows OS... Anyway, if true, can this, should >this, be tweaked? If not true, NM. > That is the stack size. Reserving a stack requires part of your virtual address space (1MB is not necessarily committed, there is a guard page on the stack that will trigger the stack growth). Since the user virtual address space is limited (2GB on most 32-bit versions of Windows, 3GB on some, not a problem on 64-bit Windows) this places an upper limit on the number of threads you can have. You can reduce the amount of stack a particular thread gets, but approaching 2000 threads is not a good thing anyway. Even 100 is a large number of threads. If your threads are often blocked waiting for I/O it doesn't hurt to have quite a few to simplify the sturcture of your code. If all of the hundreds of threads are CPU bound, some percentage of the available CPU time will be wasted with the administrative overhead of switching between the threads. But considering how fast the CPU is compared to everything else in a system including the memory... Chris Hill Chris244@aol.com
Technical Details
Message-ID:
<3e712c22.1882140705@forums.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3e6deb3f@newsgroups.borland.com> <3e6e2fb9@newsgroups.borland.com> <3e70406f@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,47731b28ebfc1a3 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-03-13 20:18:06 PST From: Chris244@aol.com (Chris Hill) Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Tweaking threads Date: Fri, 14 Mar 2003 04:14:11 GMT Message-ID: <3e712c22.1882140705@forums.borland.com> References: <3e6deb3f@newsgroups.borland.com> <3e6e2fb9@newsgroups.borland.com> <3e70406f@newsgroups.borland.com> X-Newsreader: Forte Free Agent 1.21/32.243 NNTP-Posting-Host: 12.221.66.183 X-Trace: newsgroups.borland.com 1047615249 12.221.66.183 (13 Mar 2003 20:14:09 -0800) Lines: 28 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail