public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Manfred Spraul <manfred@colorfullife.com>
To: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: wait_event_interruptible() seems non-atomic
Date: Sat, 20 Nov 2004 17:16:43 +0100	[thread overview]
Message-ID: <419F6DEB.6030606@colorfullife.com> (raw)

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

             reply	other threads:[~2004-11-20 16:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-20 16:16 Manfred Spraul [this message]
2004-11-20 16:26 ` wait_event_interruptible() seems non-atomic Jan Engelhardt
2004-11-20 18:31   ` Manfred Spraul
2004-11-21  9:40     ` Jan Engelhardt
2004-11-21 10:00       ` Manfred Spraul
2004-11-21 10:21         ` Jan Engelhardt
  -- strict thread matches above, loose matches on Subject: below --
2004-11-20 15:35 Jan Engelhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=419F6DEB.6030606@colorfullife.com \
    --to=manfred@colorfullife.com \
    --cc=jengelh@linux01.gwdg.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox