Table of Contents
Pete Zaitcev gives the following summary:
If you are in a process context (any syscall) and want to
lock other process out, use a semaphore. You can take a semaphore
and sleep (copy_from_user*( or
kmalloc(x,GFP_KERNEL)).
Otherwise (== data can be touched in an interrupt), use
spin_lock_irqsave() and
spin_unlock_irqrestore().
Avoid holding spinlock for more than 5 lines of code and
across any function call (except accessors like
readb).