Re: Thread limit reached?
- From: "Michael J. Salamone" <mikesa#at#entrek#dot#com>
- Date: Wed, 27 Dec 2006 18:31:21 -0800
In CE 5.0 and earlier, each process gets 32MB address space. And each
thread, by default, gets a 64K stack. Even if you specify less 64K is the
minimum. It may be higher depending on how, as you refer to below, build
the app or call CreateThread.
So the limit is definitely greater than 48 threads (48 X 64K = 3MB). In
fact, device.exe often has more than 100 threads running inside that
process. And most of those threads are typically blocked in a call to
WaitFor/MultipleObjects (waiting for an interrupt or shutdown event).
You're more than likely hanging for some other reason. Even if there wasn't
enough memory to create the 47th thread, CreateThread should error out.
Where is it hanging? Is it in the call to CreateThread where it hangs?
Btw, you can actually set a breakpoint in CreateThread if you want to trace
into that and see what's happening at that level. Look at schedule.c in
wincexxx\private\winceos\coreos\nk\kernel. The Shared Source is installed
when you install PB, but not by default. If you didn't install it
originally, you can go back to the installer and add it.
--
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com
"Ted Toal at Sierra Video Systems"
<TedToalatSierraVideoSystems@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9E2F0221-DC46-4751-829B-A2D590432E0B@xxxxxxxxxxxxxxxx
I wrote an app that simply creates threads one after another. Each thread
enters a loop where it just Sleep()s all the time. The main thread
creates
these threads and then displays a message that it created one. It gets to
46
threads and then the main thread hangs.
I would think that although 46 is a lot of threads, it would be nowhere
near
the limit.
I played with thread size, both in the PB linker settings for stack, and
in
the CreateThread() arguments, and neither one had any effect (I tried
stack
sizes as low as 0x2000). I have 256 MB of RAM, and much of it should be
available.
Is there a hard limit in CE of somewhere around 48 threads per process?
--
Ted Toal
.
- Follow-Ups:
- Re: Thread limit reached?
- From: Ted Toal at Sierra Video Systems
- Re: Thread limit reached?
- Prev by Date: Re: Is windows ce5.0 suport bluetooth of CF Connection
- Next by Date: Re: NETCF2 included but not built
- Previous by thread: Re: Is windows ce5.0 suport bluetooth of CF Connection
- Next by thread: Re: Thread limit reached?
- Index(es):
Relevant Pages
|