[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about your libpthread

From: Neal H. Walfield
Subject: Re: Question about your libpthread
Date: Mon, 13 Aug 2012 11:38:02 +0200
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Goj┼Ź) APEL/10.8 Emacs/23.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

I've add bug-hurd to the cc.

At Mon, 13 Aug 2012 11:16:26 +0200,
Richard Braun wrote:
> On Sun, Aug 12, 2012 at 07:03:06PM +0200, Neal H. Walfield wrote:
> > But, if it is a generally useful function, I don't see why not to
> > expose it as a general function.  Just add _np at the end of the
> > function name.
> Sorry to disturb you again, but I found something surprising when using
> libpthread. It seems the stack size can't be changed with
> pthread_attr_setstacksize. There is a comment about alignment but I'm
> not sure I understand why it prevents different stack sizes.
> This is important for my current work, as cthreads use 64k stacks
> whereas pthreads use 2 MiB, which strongly limits the maximum number of
> threads, and may prevent pagers like ext2fs to service some paging
> requests under thread storms (the problem exists with cthreads of
> course, but I'd like to reduce its likeliness by at least approaching
> what was done with them).

The problem has to do with the recycling of stacks.  The problem is
that a thread cannot easily free its own stack when it exits.  If it
frees its stack, it can't free it's kernel thread and vice versa.  To
work around this, the thread does neither.  Instead, later threads
reuse the stack and kernel thread.  If the stacks had a non-standard,
we would need some additional code to find an appropriately sized
stack or implement a mechanism to clean up exited threads

reply via email to

[Prev in Thread] Current Thread [Next in Thread]