Date: Sun, 21 Dec 2008 23:52:33 +0100 From: Ed Schouten <ed@80386.nl> To: Kostik Belousov <kostikbel@gmail.com> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r186382 - head/sys/kern Message-ID: <20081221225233.GV1176@hoeg.nl> In-Reply-To: <20081221221014.GJ2038@deviant.kiev.zoral.com.ua> References: <200812212116.mBLLGvPj042566@svn.freebsd.org> <20081221221014.GJ2038@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
--5QcriFbbFkKgT3aH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Kostik, * Kostik Belousov <kostikbel@gmail.com> 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 <ed@80386.nl> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081221225233.GV1176>