From owner-svn-src-all@FreeBSD.ORG Sun Dec 21 22:52:34 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1704106564A; Sun, 21 Dec 2008 22:52:34 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from palm.hoeg.nl (mx0.hoeg.nl [IPv6:2001:7b8:613:100::211]) by mx1.freebsd.org (Postfix) with ESMTP id 7F9128FC1C; Sun, 21 Dec 2008 22:52:34 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: by palm.hoeg.nl (Postfix, from userid 1000) id B48391CE1E; Sun, 21 Dec 2008 23:52:33 +0100 (CET) Date: Sun, 21 Dec 2008 23:52:33 +0100 From: Ed Schouten To: Kostik Belousov Message-ID: <20081221225233.GV1176@hoeg.nl> References: <200812212116.mBLLGvPj042566@svn.freebsd.org> <20081221221014.GJ2038@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5QcriFbbFkKgT3aH" Content-Disposition: inline In-Reply-To: <20081221221014.GJ2038@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r186382 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Dec 2008 22:52:35 -0000 --5QcriFbbFkKgT3aH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Kostik, * Kostik Belousov wrote: > I was always curious whether our cv code guarantees that there is no > a spurious wakeup. If the spurious wakeup can happen, then setting > PTS_FINISHED before calling cv_broadcast() still does not solve > the possible race. >=20 > Assume that waiting thread is woken up, and ptsdrv_close() still did > not set PTS_FINISHED. The ptsdev_read() locked the mutex, rechecked > the condition (that is false still), and preempted for the > ptsdrv_close() thread. This thread sets flag and issues broadcast. > Then, the ptsdrv_read() thread is put to sleep, having lost a wakeup. >=20 > I think that mutex shall be acquired around setting flag and wakeups. > scheduled, it=20 Everything was already done correctly with respect to locking. All the routines that use `pts_flags' already hold the per-TTY lock. The actual problem is that KNOTE_LOCKED() (inside ptsdrv_*wakeup()) calls pts_kqops_read_event() synchronously. This means that we must set PTS_FINISHED on beforehand. --=20 Ed Schouten WWW: http://80386.nl/ --5QcriFbbFkKgT3aH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAklOyLEACgkQ52SDGA2eCwWGxgCeLeE1EjUXUIcQJVjATJ33rl8q 3zUAmweHAbe/WCkGRwIB/UXJfKQ/igYn =otm5 -----END PGP SIGNATURE----- --5QcriFbbFkKgT3aH--