From owner-freebsd-current@FreeBSD.ORG Thu Sep 18 16:57:52 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04C74106564A for ; Thu, 18 Sep 2008 16:57:52 +0000 (UTC) (envelope-from naylor.b.david@gmail.com) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.184]) by mx1.freebsd.org (Postfix) with ESMTP id 8494E8FC21 for ; Thu, 18 Sep 2008 16:57:51 +0000 (UTC) (envelope-from naylor.b.david@gmail.com) Received: by nf-out-0910.google.com with SMTP id h3so2106428nfh.33 for ; Thu, 18 Sep 2008 09:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:organization:to:subject :date:user-agent:cc:references:in-reply-to:mime-version:content-type :content-transfer-encoding:message-id; bh=wrL9sCz+0pG7K4CSaeG9SoNuUQhjevYB2gRz9NAe6xI=; b=su+RN58vAVEx8ICzHsmM8QjUXHwlYPJaVPeMJ6pa72jg4lN1i6svZY/iezlt7NaGUl gtbn69wCTgNKEO0i9yDHW/Fv4bH3G1yrvJOGbPDT5miqnl1hUVgEEJ/JM6/ZXAfH53FI jhq3kBTkIAe0l8bCI3Cpj8iO0+HbnMiwHttUg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:organization:to:subject:date:user-agent:cc:references :in-reply-to:mime-version:content-type:content-transfer-encoding :message-id; b=xAFA6bNZzXnRfnmc2kwIZiWpS2XMvlJrxwOZnMQzq0NWx/GBVAJ6Vq70AT64LjorSU fJjR+5cUftR6sw0K8b3ZBLQPbTeEcvXX5XzKe2Y+EJF58mp+YMD9+xyxY1IZ0h2RdM3G Q19v98YTuiHQTQHvuBSkENL27bf2kupIRrpdE= Received: by 10.103.250.11 with SMTP id c11mr3112304mus.23.1221757069906; Thu, 18 Sep 2008 09:57:49 -0700 (PDT) Received: from ?0.0.0.0? ( [196.34.241.123]) by mx.google.com with ESMTPS id t10sm11007974muh.16.2008.09.18.09.57.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 18 Sep 2008 09:57:48 -0700 (PDT) From: David Naylor Organization: Private To: Tom Evans Date: Thu, 18 Sep 2008 18:57:21 +0200 User-Agent: KMail/1.9.7 References: <200809180631.47071.naylor.b.david@gmail.com> <1221744832.68732.4.camel@localhost> In-Reply-To: <1221744832.68732.4.camel@localhost> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart42174261.jbxUDPrD5S"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200809181857.25872.naylor.b.david@gmail.com> X-Mailman-Approved-At: Thu, 18 Sep 2008 17:04:22 +0000 Cc: freebsd-current@freebsd.org Subject: Re: FreeBSD deadlock (with fork?) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Sep 2008 16:57:52 -0000 --nextPart42174261.jbxUDPrD5S Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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) fr= om > > 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). =20 > > I think the former will not work.. Is there any reason for this and is this a FreeBSD limitation or a general= =20 problem? =20 The problem is that my program has to have threads (or something similar)=20 since it handles lots of IO bound processes concurrently so is there a=20 work-a-round for this problem? I could limit the forking to a single thread (which I tried and did not wor= k)=20 but perhaps I need to have it fork from the master thread? One option I considered was forking a 'slave' program that then does all th= e=20 forking but that will become exceedingly complex (with the communication=20 between the 'slave' and the threads). =20 Lastly, how does GUIs, such as Qt, handle forking since they are threaded a= nd=20 some do fork? =20 > > Cheers > > Tom Regards David --nextPart42174261.jbxUDPrD5S Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQBI0oh1UaaFgP9pFrIRAg7tAJ0YftXpRyZmILJTgPYT8tuaZp94zACfQ9eQ 9ky/Af7G8yBCGAeU2nsQks0= =YYdj -----END PGP SIGNATURE----- --nextPart42174261.jbxUDPrD5S--