On Thu, 2019-08-22 at 10:33 +0300, Nadav Har'El wrote:
> You're right, it seems there's should be a "return" in the recursive
> case! 
> That being said, I think the spurious wakeup doesn't cause any harm,
> because the wait code rwlock::writer_wait_lockable() loops, and if a
> thread
> is woken while the lock is still taken, it just goes to sleep again.
> It will just lose it's good spot on the queue :-(

I wasn't sure that was the case. I put an assert in
writer_wait_lockable() (see below) and I was able to trigger it by
having 1 thread take the write lock twice, then a second thread attempt
to take the write lock. When the first thread released, the second
thread triggers the assert.

void rwlock::writer_wait_lockable()
{
    while (true) {
        if (write_lockable()) {
            return;
        }

        _write_waiters.wait(_mtx);
        assert((_wowner == sched::thread::current()) ||
               (_wowner == nullptr));

    }
}

Rick

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/3337ae47fbb6a29f11440e3c5bc78549e6fbe8da.camel%40rossfell.co.uk.

Reply via email to