On 2011-08-20 at 05:17:54 [+0200], Rene Gollent <anevilyak@xxxxxxxxx> wrote: > On Fri, Aug 19, 2011 at 10:13 PM, Earl Pottinger > <earl_colby_pottinger@xxxxxxxxx> wrote: > > Should I be disabling interrupts only with spin-locks or will disabling > > interrupts work with semaphores as well???? > > You should generally avoid disabling interrupts unless you absolutely > have to, and in any case, if you are in the situation where it's > unavoidable, spinlocks are about the only thing you'll be able to use, > since semaphores generally require being able to reschedule/preempt, > which isn't possible with ints disabled. Also note that there are more efficient locking primitives than semaphores available in the kernel (mutex, rw_lock,...). The API is not public, so third-party drivers shouldn't use them, but any driver that ends up in the repository is free to use it. Regarding spinlocks, the basic rule is that you need to use them, when you need locking in a context where interrupts are disabled (e.g. in an interrupt handler). In all other situations you should generally use another locking primitive (though there are (rare) circumstances where a spinlock is preferrable for performance reasons). CU, Ingo