Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Maximum Threads

22 views
Skip to first unread message

Mark Wickman

unread,
Nov 4, 1996, 3:00:00 AM11/4/96
to

Does anyone know of a rule of thumb etc. for what is considered too
many threads to execute at once ?

I know it is based on many different factors, but in theory my
application could create 1000's of threads so I need a user
configurable limit to impliment in the settings and need some
guidelines on actual numbers. I have searched through the help files
in VC++ plus on MSDN plus on the Internet without much luck.

Does anyone have any ideas ?

Thanks

------------------------------------------------
Mark Wickman
http://light.iinet.net.au/~wstone/
wst...@light.iinet.net.au CIS:100517,745
------------------------------------------------
** NEW RELEASE **
Download Manager for Win3.x & Win95
- Stores and manages downloaded files with Keywords,Abstract etc.-
ftp://light.iinet.net.au/pub/unsup/Downman/Win3/
ftp://light.iinet.net.au/pub/unsup/Downman/Win95/
------------------------------------------------

Dan Shappir

unread,
Nov 4, 1996, 3:00:00 AM11/4/96
to

Mark Wickman <wst...@light.iinet.net.au> wrote in article
<32843e2f...@news.m.iinet.net.au>...

> Does anyone know of a rule of thumb etc. for what is considered too
> many threads to execute at once ?
>
> I know it is based on many different factors, but in theory my
> application could create 1000's of threads so I need a user
> configurable limit to impliment in the settings and need some
> guidelines on actual numbers. I have searched through the help files
> in VC++ plus on MSDN plus on the Internet without much luck.
>
> Does anyone have any ideas ?

I'm also unaware of any documented restrictions on the number of
threads, but if your application can spawn 1000's you should rethink
your design. There are several reasons for this:
1. Threads require and acquire system resources (even worker threads).
Even if you don't reach the limit you are going to adversely effect
system performance.
2. Context switches are expensive, especially on Windows 95.
Many threads often mean many context switches.
Even if not I suspect that many threads will result in longer context
switches.
3. The different Win32 platforms probably have different restrictions
on the number of threads.
4. You may cause other threaded applications to fail.
If you are only targeting the new NT you may want to look into fibers but
I think the best solution is to maintain state in C++ objects instead of on
a thread's stack.

Dan
==============================================================
Dan Shappir
http://www.math.tau.ac.il/~shappir
36 Rembrandt St. Tel-Aviv Israel 64045 Tel. (972)3-5246879


Joe Hagen

unread,
Nov 5, 1996, 3:00:00 AM11/5/96
to

Mark,
Paula Tomlinson addressed this issue in the APR '96 issue of
Windows Developer's Journal.

Her advice was to consider the MAXIMUM_WAIT_OBJECTS (64
in my WINNT.H) and the number of processors in the system:

maxThreads=MIN(MAXIMUM_WAIT_OBJECTS,2x#procs)

So, a typical value for a Pentium PC is probably two worker threads.

I highly recommend reading her articles, as she covers everything
from NT's registry vs Win95, UNICODE, I/O completion ports,
and writing NT services.

Joe.

--
jdh...@itis.com

0 new messages