Date: Thu, 18 Sep 2008 19:09:01 +0200 From: Jille Timmermans <jille@quis.cx> To: David Naylor <naylor.b.david@gmail.com> Cc: Tom Evans <tevans.uk@googlemail.com>, freebsd-current@freebsd.org Subject: Re: FreeBSD deadlock (with fork?) Message-ID: <48D28B2D.90204@quis.cx> In-Reply-To: <200809181857.25872.naylor.b.david@gmail.com> References: <200809180631.47071.naylor.b.david@gmail.com> <1221744832.68732.4.camel@localhost> <200809181857.25872.naylor.b.david@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
David Naylor schreef: > On Thursday 18 September 2008 15:33:52 Tom Evans wrote: >> On Thu, 2008-09-18 at 06:31 +0200, David Naylor wrote: >>> Hi, >>> >>> I have a program that spawns a lot of subprocesses (with pipes open) from >>> multiple threads. The problem is the program often deadlocks, but not >>> consistently. Sometimes the program can run over 5 times to competition >>> without incidence and yet othertimes it locks within a few seconds. >> Do you create threads, which then fork(), or do you fork() and then create >> threads? > > I have many threads that then fork. (aka forking threads). If you fork, the child will only have one thread, the one that called fork(). The parent is left as is. (This prevents a lot of races; mostly in programs that fork() and execve()) > >> I think the former will not work.. > > Is there any reason for this and is this a FreeBSD limitation or a general > problem? I assume all fork()ing OS's will do this. > > The problem is that my program has to have threads (or something similar) > since it handles lots of IO bound processes concurrently so is there a > work-a-round for this problem? > > I could limit the forking to a single thread (which I tried and did not work) > but perhaps I need to have it fork from the master thread? Doesn't matter wrt the single-threaddedness of the child (which can create threads after being forked off) -- Jille > > One option I considered was forking a 'slave' program that then does all the > forking but that will become exceedingly complex (with the communication > between the 'slave' and the threads). > > Lastly, how does GUIs, such as Qt, handle forking since they are threaded and > some do fork? >> Cheers >> >> Tom > > Regards > > David
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48D28B2D.90204>