[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about your libpthread
From: |
Richard Braun |
Subject: |
Re: Question about your libpthread |
Date: |
Mon, 13 Aug 2012 11:54:17 +0200 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Mon, Aug 13, 2012 at 11:38:02AM +0200, Neal H. Walfield wrote:
> 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
> periodically.
It seems __pthread_create_internal does a bit of the two, i.e. It
attempts to "find" a suitable stack by checking the size of the recycled
thread, and if the size doesn't fit, it releases it, leaving itself
in a state that tells later functions to allocate a new stack. "Fit"
here means the stack size is the default. Why not check against the real
stack size as stored in the __pthread structure ?
In addition, here you only mention the recylcing problem, not the
threadvar alignment problem. Or is there no such problem ?
--
Richard Braun