From owner-freebsd-arch@FreeBSD.ORG Sun Apr 4 17:51:41 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EC219106564A for ; Sun, 4 Apr 2010 17:51:41 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id B1E738FC0C for ; Sun, 4 Apr 2010 17:51:41 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 1987D35A847 for ; Sun, 4 Apr 2010 19:51:41 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 058A217531; Sun, 4 Apr 2010 19:51:41 +0200 (CEST) Date: Sun, 4 Apr 2010 19:51:40 +0200 From: Jilles Tjoelker To: freebsd-arch@freebsd.org Message-ID: <20100404175140.GB40499@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Subject: so_rcv_sx, deadlkres, SIGSTOP X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Apr 2010 17:51:42 -0000 The SX locks so_snd_sx and so_rcv_sx can be legitimately held for arbitrary amounts of time, while waiting until a send or recv is possible. Any other threads wanting to send/recv on the socket will sleep interruptibly on the corresponding SX. If deadlkres is activated, it may detect a deadlock even though there is no problem. If a SIGSTOP or similar comes in while waiting until send/recv is possible, the SX is held across the suspension and noone will be able to send/recv on the socket until the process is resumed. On the other hand a thread waiting for the SX can be suspended without harm. Adding PBDRY to various sleeps may help but may also introduce other problems (SIGSTOP disturbing the functioning of the process more, possibly with stuff like SO_RCVTIMEO). Example (using the fact that fifos are implemented using sockets): term1% mkfifo testfifo term1% cat >testfifo term2% cat testfifo term3% cat testfifo Letting this sit for half an hour will trigger deadlkres. If the reader in term2 (started first) is suspended, the reader in term3 will not get any input written to the fifo. -- Jilles Tjoelker