On Fri, Mar 24, 2000 at 05:19:41PM +0530, Kedar Patankar wrote:
>       BTW does anyone know what happens to stack? IIRC, linux uses the
> bottom of data area as stack? Does it get duplicated, and properly mapped
> so that each thread sees its own stack??

The stack normally starts just below the kernel (0xbfffffff) and grows
towards the heap.

http://pauillac.inria.fr/~xleroy/linuxthreads/README

- The stacks for the threads are allocated high in the memory space,
  below the stack of the initial process, and spaced 2M apart.
  Stacks are allocated with the "grow on demand" flag, so they don't
  use much virtual space initially (4k, currently), but can grow
  up to 2M if needed.

  Reserving such a large address space for each thread means that,
  on a 32-bit architecture, no more than about 1000 threads can
  coexist (assuming a 2Gb address space for user processes),
  but this is reasonable, since each thread uses up one entry in the
  kernel's process table, which is usually limited to 512 processes.

  Another potential problem of the "grow on demand" scheme is that
  nothing prevents the user from mmap'ing something in the 2M address
  window reserved for a thread stack, possibly causing later extensions of
  that stack to fail. Mapping at fixed addresses should be avoided
  when using this library.'

        -Arun

-----------------------------------------------------------------------
For information on this and other Linux India mailing lists check out
http://lists.linux-india.org/

Reply via email to