Hi, > 2. There isÂsome below piece of kernelÂcode running on Quad core Machine. > ÂÂÂ spin_lock_irqsave(&lock, flags); > ÂÂÂÂsome_large_critical_section //sleep of 5 minutes > ÂÂÂ //I know there should be as small as possible task in critical section > ÂÂÂ // treat this as an example only > ÂÂÂ spin_lock_irqrestore(); > 3. One of the CPU core tries to execute this code and so acquires the lock. > 4. Now, second core is also goes to execute same piece of code and so will > keep spinning for lock > > Now, the question is > WillÂEVERÂsecond CPU core get chance to execute another task ? > Ever ifÂtimeslice is over for the current task ? As far as I understand (from quickly reading include/linux/spinlock*.h), kernel preemption is disabled as long as a spin lock is used (and in your case, as soon as spin_lock_irqsave is entered). This means that a core that started acquiring a spinlock will not execute another task not only until the lock is acquired, but until the lock is released. > What if scheduler code is running on CPU core-3 and sees that > timesliceÂfor task running on CPU core-2 has expired ? AFAIK (that is, not very far) the scheduler code only cares for the current core and does not assign tasks to others. But even if it did, it would not have any way to stop the second core until it releases the spin lock. So in any case, both core 1 and core 2 will be blocked until they release the lock. Alex. _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies