Re: When is to preempt safe?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

On 00:19 Sun 09 Oct     , Parmenides wrote:
> 2011/10/8 Chetan Nanda <chetannanda@xxxxxxxxx>:
> >
> > 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.

If you want your tasks to be preemptable while holding locks, I do not
recommend busywaiting locks, but rather putting task which tries to aquire a
busy lock should to sleep. The task which is holding the lock will then have a
chance to run and complete the critical section. In real time systems, the
priority of the task holding the lock is usually temporarily increased to the
priority of the process trying to aquire the lock.

	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux