lkml.org 
[lkml]   [2004]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 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/

\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.036 / U:2.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site