2011/10/8 Michael Blizek <michi1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>: > Hi! > > There are 2 different kind of locks: Those which can be preempted (mutex and > semaphores) and those which cannot (spinlocks). Spinlocks do busy waiting > until the lock is released. On single cpu systems, the are optimised into > enable/disable preemption. Spinlocks have to be used if the data it protects > is partly accessed in code paths which have preemption disables for other > reasons (e.g. being interrupt handler). This is because otherwise you have a > problem if you cannot preempt, but need to aquire a lock which is held by a > "thread" which has been preempted. > Except for interrupt handler, is there any other code path which cannot be preempted but need to obtain a lock. If not, I think a thread holding a spinlock can disable interrupt when it is in critical section to resolve this problem, rather than disable preemption. _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies