叶剑君 wrote:
> pthread_create a new thread need how much memory resources?
> does the new thread need new stack?

Yes, it allocates a new stack and some small data block.

The data is quite small, but will be larger if you use a lot of
thread-specific data.  (E.g. using recent GCC and "__thread").

The following applies to uClibc-0.9.26, and LinuxThreads:

On devices with no MMU, the stack is 16k for new threads, even if you
change the initial thread stack size using -Wl,-elf2flt=-s32768 (for
example).  This is too small for some programs.  You can change this
using pthread_attr_setstacksize.

On devices with an MMU, the stack is allocated on demand, so it only
takes as much real memory as the program uses.  However, it will use
4M of virtual address range (by default), limiting the number of
threads you can create on a 32-bit device with MMU, unless you change
this.

Enjoy,
-- Jamie
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to