From: "Manfred Spraul" <manfred@colorfullife.com>
To: "Russ Lewis" <russ@deming-os.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: Safely giving up a lock before sleeping
Date: Tue, 24 Jul 2001 17:20:06 +0200 [thread overview]
Message-ID: <000b01c11454$233a0d60$010411ac@local> (raw)
> If I implement this by calling spin_unlock_irqrestore() immediately
> followed by interruptible_sleep_on(), then I have a race condition
> where I could release the lock and immediately have a bottom half
> handler on another processor grab it, put data in the queue, and wake
> the wait queue. My original (user-side) process then happily goes
> to sleep, unaware that new information is available.
DO NOT use sleep_on in new code.
The correct replacement is wait_event() in <linux/wait.h> if the
spinlock is a normal (i.e. non-irq) spinlock.
Your spinlock is probably a spin_lock_irq() or spin_lock_bh() lock, then
you must build your own wait_event() wrapper.
check <linux/raid/md_k.h> for a wrapper with spin_lock_irq
(wait_event_lock_irq)
The mouse driver sample in linux/documentation also explains the correct
way to release a lock and schedule.
--
Manfred
next reply other threads:[~2001-07-24 15:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-24 15:20 Manfred Spraul [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-07-23 21:49 Safely giving up a lock before sleeping Russ Lewis
2001-07-24 12:39 ` Richard B. Johnson
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='000b01c11454$233a0d60$010411ac@local' \
--to=manfred@colorfullife.com \
--cc=linux-kernel@vger.kernel.org \
--cc=russ@deming-os.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