Re: svn commit: r186382 - head/sys/kern

[ Available lists | Index of svn-src-all | Month of Dec 2008 | Week of 21 Dec 2008 | Raw email | View thread | Wrap long lines | Reply | Tag ]
From
Ed Schouten <ed@80386.nl>
Date
21 Dec 2008 22:52:34
Subject
Re: svn commit: r186382 - head/sys/kern
Message-ID
20081221225233.GV1176@hoeg.nl


[ Hide this part ]
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.
>
> 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.
>
> I think that mutex shall be acquired around setting flag and wakeups.
> scheduled, it

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.

--
Ed Schouten <ed@80386.nl>
WWW: http://80386.nl/


[ Show this part (application/pgp-signature) ]

Elapsed time: 0.131 seconds