Messages in this thread | | | Date | Tue, 10 Apr 2001 11:41:28 +0900 | From | Tachino Nobuhiro <> | Subject | Re: rw_semaphores |
| |
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/
| |