When is to preempt safe?

Dave Hylands dhylands at gmail.com
Sat Oct 8 13:32:59 EDT 2011


Hi guys,

Send to list this time.

On Sat, Oct 8, 2011 at 10:09 AM, Daniel Baluta <daniel.baluta at gmail.com> wrote:
> On Sat, Oct 8, 2011 at 7:19 PM, Parmenides <mobile.parmenides at gmail.com> wrote:
>> 2011/10/8 Chetan Nanda <chetannanda at gmail.com>:
>>>
>>> New task pick by scheduler may try to get the same lock resulting in
>>> deadlock
>>
>> It seems that this kind of deadlock may be removed eventually. Suppose
>> that we have a task A, which is holding a spinlock. If A is preempted
>> by task B which try to obtain the same spinlock. Although B has to
>> busy wait, it will end up with be preempted owing to using up its
>> timeslice. Therefore, A has chance to be selected by shechedler and
>> release the spinlock. Then, B will go on when it is selected by the
>> secheduler next time.
>
> Well, I think that if task B has higher priority than task A, then A would
> never have the chance to release the lock.

Task A probably should have acquired the spinlock with interrupts
and/or preemption
disabled, and then it would have never lost control. If task B is also
running, then it's running a separate core, and task A will still be
able to continue running.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com



More information about the Kernelnewbies mailing list