Re: Number of threads per process

From: Casper H.S. Dik (Casper.Dik_at_Sun.COM)
Date: 01/06/04


Date: 06 Jan 2004 13:59:53 GMT

Gavin Maltby <G_a_v_i_n.M_a_l_t_b_y@sun.com> writes:

>I don't think a file descriptor is used per thread created (I'd
>be very surprised). To create the stack for the new thread
>(if not preconstructed) some anon memory is mapped, and
>(at least in the old libthread) that involves opening
>/dev/zero (it wasn't held open). So if you run out of
>file descriptors you can not be able to create threads
>(since the open of /dev/zero can fail; not sure
>how things are done in the newer libthread).

MAP_ANON is used to allocate thread stacks starting with Solaris 8 when
MAP_ANON was introduced in Solaris. Since that moment file descriptors
are not involved in creating threads.

Prior to that a cached fd to /dev/zero was used.

>The main limit on the number of threads you can create is
>VM space, for a 32-bit application anyway. Only so many
>stacks can fit in 32-bits, and each stack normally has
>a further 8K guardpage (unmapped, but takes VM space).
>When you hit this limit depends on the the stack size
>being requested each time. Again a truss will let you
>observe this.

I think that on UltraSPARC system the alignment is always on 64K
boundaries.

Casper

-- 
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.