[PATCH] Switch leds from mutex to spinlock to work in atomic contexts
Werner Almesberger
werner at openmoko.org
Mon Jul 7 14:57:13 CEST 2008
Holger Freyther wrote:
> Switch from using a mutex to spinlock
> to control the brightnes of the leds...
This is bogus. Spinlocks don't do anything on a uniprocessor - they're
even removed during compilation.
Here are some choices of what you can do if you need to lock something
that can be called from an interrupt:
- move it into a workqueue, so you can use locks that sleep or even
omit them
- similarly, use a tasklet instead of a lock
- don't lock when in the interrupt code, and protect the non-interupt
code by disabling interrupts while in the critical section
(careful about what this does to interrupt latency !)
- in the interrupt, probe the lock and do not perform the action if
locked
etc.
- Werner
More information about the openmoko-kernel
mailing list