Messages in this thread | | | Date | Sat, 20 Nov 2004 17:16:43 +0100 | From | Manfred Spraul <> | Subject | Re: wait_event_interruptible() seems non-atomic |
| |
Hi Jan,
>I would like to also lock Buffer_lock around BufRP != BufWP, but don't see a >way on how to accomplish this. > > > This is not a problem: You compare BufRP and BufWP twice: once within wait_event_interruptible (without locking) and again a second test in your uif_read function with locking. You are right that the test within wait_event_interruptible is optimistic: a concurrent uif_read could read the new data before the initial uif_read has a chance to acquire the BufferLock. But it doesn't matter: AFAICS the test is optimistic, it can't happen that BufRP and WP are actually different and wait_event sleeps. And the external loop within uif_read() just loops if the race that you describe happened.
Btw, could you post a link to the complete driver when asking questions? For example the use of down_interruptible() looks wrong to me, I'd use plain down().
-- Manfred - 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/
| |