Re: rw_semaphores

From: Tachino Nobuhiro (tachino@open.nm.fujitsu.co.jp)
Date: Mon Apr 09 2001 - 21:41:28 EST


Hello,

At Sun, 8 Apr 2001 20:08:13 -0700 (PDT),
Linus Torvalds wrote:
>
> Can anybody shoot any holes in this? I haven't actually tested it, but
> race conditions in locking primitives are slippery things, and I'd much
> rather have an algorithm we can _think_ about and prove to be working. And
> I think the above one is provably correct.

  I am not familiar with semaphore or x86, so this may not be correct,
but if the following sequence is possible, the writer can call wake_up()
before the reader calls add_wait_queue() and reader may sleep forever.
Is it possible?

Reader Writer

    down_read:
        lock incl (%sem)
        js __down_read_failed
                                                    up_write:
                                                        lock andl $0x3fffffff,(%sem)
                                                        jne __up_write_wakeup

                                                    __up_write_wakeup:
                                                        spin_lock(&sem->lock);
                                                        wake_up(&sem->waiters);
                                                        spin_unlock(&sem->lock);
    __down_read_failed:
        spin_lock(%sem->lock)
        add_wait_queue(&sem->waiters, &wait);
        .
        .
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 15 2001 - 21:00:12 EST