Re: Thread limit reached?

Tech-Archive recommends: Fix windows errors by optimizing your registry



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


.



Relevant Pages

  • Re: Thread limit reached?
    ... Remember that CreateThread's stack-size parameter specifies the stack commit size, ... I'm not sure why you're getting a hang in CreateThread() though. ... when you install PB, but not by default. ...
    (microsoft.public.windowsce.embedded)
  • Evil autorun CD - ideas ? downloadable exploits anywhere ?
    ... He would bake a stack of CD's and bring them to a conference. ... collected data to a temporary server that I will install on the network. ... This idea has one big risk - suppose someone takes the CD home. ... would be committing a criminal act if I exploited his home computer. ...
    (Pen-Test)
  • Re: SBMJOB #LIBRARY problem.
    ... You can install it on the machine that does not have a #LIBRARY. ... the library you specified omit the command. ... first entry in the call stack. ... the first entry in the call stack. ...
    (comp.sys.ibm.as400.misc)
  • Re: Thread Stacks
    ... >> to since the commit pages are automatically expanded. ... > taking individual page faults for each 4k page in the stack. ... > parameter of the CreateThread, CreateRemoteThread, or CreateFiber ... > reserve size is the default reserve size specified in the executable ...
    (comp.arch)
  • Re: Cisco VPN corrupts winsock
    ... > wireless card and using Device Manager to remove your NIC adapter. ... > XP should redetect it and reinstall it giving you your IP stack back. ... >> One of our users was told to install the Cisco VPN client. ...
    (microsoft.public.windowsxp.general)