* is there a spin_trylock_irqsave?
@ 2002-02-27 2:14 Gigi Sebastian Alapatt
2002-02-27 2:27 ` Robert Love
0 siblings, 1 reply; 2+ messages in thread
From: Gigi Sebastian Alapatt @ 2002-02-27 2:14 UTC (permalink / raw)
To: linux-kernel
Is there a spin_trylock_irqsave?
Basicially
spin_once_trylock_irqsave?
_________________________________________________________________
Join the worlds largest e-mail service with MSN Hotmail.
http://www.hotmail.com
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: is there a spin_trylock_irqsave?
2002-02-27 2:14 is there a spin_trylock_irqsave? Gigi Sebastian Alapatt
@ 2002-02-27 2:27 ` Robert Love
0 siblings, 0 replies; 2+ messages in thread
From: Robert Love @ 2002-02-27 2:27 UTC (permalink / raw)
To: Gigi Sebastian Alapatt; +Cc: linux-kernel
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 */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-02-27 2:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-27 2:14 is there a spin_trylock_irqsave? Gigi Sebastian Alapatt
2002-02-27 2:27 ` Robert Love
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox