From: Robert Love <rml@tech9.net>
To: Gigi Sebastian Alapatt <ggnet@hotmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: is there a spin_trylock_irqsave?
Date: 26 Feb 2002 21:27:37 -0500 [thread overview]
Message-ID: <1014776857.879.104.camel@phantasy> (raw)
In-Reply-To: <F132iGXix4A2DreBBsQ00008ce6@hotmail.com>
In-Reply-To: <F132iGXix4A2DreBBsQ00008ce6@hotmail.com>
On Tue, 2002-02-26 at 21:14, Gigi Sebastian Alapatt wrote:
>
> Is there a spin_trylock_irqsave?
>
> Basicially
>
> spin_once_trylock_irqsave?
No, although there is a spin_trylock_bh for whatever reason.
Implementing this would not be hard, you just need to disable irqs
_before_ spin_trylock to avoid a race. Something like:
int dog;
unsigned long flags;
local_irq_save(flags);
dog = spin_trylock(lock);
if (!dog)
local_irq_restore(flags);
Oh, I'll just attach a patch. Enjoy,
Robert Love
diff -urN linus/include/linux/spinlock.h linux/include/linux/spinlock.h
--- linus/include/linux/spinlock.h Tue Feb 26 20:17:12 2002
+++ linux/include/linux/spinlock.h Tue Feb 26 21:22:22 2002
@@ -38,6 +38,12 @@
__r = spin_trylock(lock); \
if (!__r) local_bh_enable(); \
__r; })
+#define spin_trylock_irqsave(lock, flags) ({ int __r; \
+ local_irq_save(flags); \
+ __r = spin_trylock(lock); \
+ if (!__r) \
+ local_irq_restore(flags); \
+ __r; })
/* Must define these before including other files, inline functions need them */
prev parent reply other threads:[~2002-02-27 2:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-27 2:14 is there a spin_trylock_irqsave? Gigi Sebastian Alapatt
2002-02-27 2:27 ` Robert Love [this message]
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=1014776857.879.104.camel@phantasy \
--to=rml@tech9.net \
--cc=ggnet@hotmail.com \
--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