Date: Sat, 24 Jan 1998 17:47:43 +1100 (EST) From: John Birrell <jb@cimlogic.com.au> To: robert@cyrus.watson.org Cc: hackers@FreeBSD.ORG Subject: Re: pthreads implementation in 3.0 (fwd) Message-ID: <199801240647.RAA10463@cimlogic.com.au> In-Reply-To: <Pine.BSF.3.96.980124005636.5088g-100000@cyrus.watson.org> from Robert Watson at "Jan 24, 98 01:05:51 am"
next in thread | previous in thread | raw e-mail | index | archive | help
Robert Watson wrote: > > I sent this to questions, but it has been suggested to me that hackers may > have been a preferred destination :). I can't handle the volume of messages that -questions generates. Sorry. > Quick questions about the pthreads implementation: > > 1. Is there a thread-safe fork (as found in the Solaris pthreads fork() or > lwp fork1()) that only copies the current thread (not the current process > and all of its threads). I am working with threads and need to fork/exec > another process, but current behavior duplicates all existing threads not > just the one that wishes to cause another program to execute. Is there a > known workaround to this? :) The Solaris fork() library call > implementation claims that it is pthreads compliant; this would make ours > less compliant (on the other hand, our fork does not claim to be > compliant, so this might not be a problem as such.) The current implementation is not strictly POSIX. This should be fixed. The required behavour is: "If a multithreaded process calls fork(), the new process shall contain a replica of the calling thread and it's entire address space, possibly including the states of any mutexes and other resources." > > 2. As an alternative, is there a call that can be used to suspend > threading (leaving the current thread in the foreground) such that the > process could fork, do it's little fork thing, then reenable threading to > perform a threaded wait for the child to finish. In the mean time, the > forked child would not be threading, so the rest of the threads would not > be awake to cause problems. There is a call that will make a process single threaded. This was added as an extension (allowed by POSIX) for Java. Try pthread_single_np() and pthread_multi_np(). But what you really want is the correct behaviour. I'm in the middle of doing something else that prevents me for testing out such a change. If I send you a patch, are you in a position to test it? You'll need to rebuild libc_r. Regards, -- John Birrell - jb@cimlogic.com.au; jb@netbsd.org; jb@freebsd.org CIMlogic Pty Ltd, GPO Box 117A, Melbourne Vic 3001, Australia +61 418 353 137
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199801240647.RAA10463>