lkml.org 
[lkml]   [2002]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] threading fix, tid-2.5.47-A3
Ulrich Drepper wrote:
> [...] It the very basic concept of always having a correct
> thread descriptor. A process created with fork() from an MT app is
> different from one created with fork() from a single threaded app. In
> the latter case the thread descriptors are not used and can contain
> garbage. In the former case the descriptor better be correct all the
> time. It basically the same problem as with setting the TLS "register".
> clone() get the CLONE_TLS flag because the child and parent have
> (potentially) different TLS address and it is not possible to set the
> value before the fork() call (since the parent would have the wrong
> value for some time) nor after the fork() (since then there would be a
> window for a signal to arrive for an uninitialized thread).

Ok, I understand now.

1. You need the child to have a valid thread descriptor immediately after
fork(), and the parent's thread descriptor to be the same
before and after fork().

2. At all times, get_current_thread()->tid must return the current
thread's tid in both the parent and child.

That is fine. Just allocate a new TLS for the child, use
CLONE_SETTID|CLONE_CLEARTID|CLONE_SETTLS in your threaded fork(), and
pass the child's tid address (in the child's tls area).
It does require allocating a new TLS area on fork(). Is that a
problem?

cheers,
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:31    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site