On Sunday 14 January 2001 01:06, george anzinger wrote:
> Nigel Gamble wrote:
> > On Sat, 13 Jan 2001, Roger Larsson wrote:
> > > A rethinking of the rescheduling strategy...
> >
> > Actually, I think you have more-or-less described how successful
> > preemptible kernels have already been developed, given that your
> > "sleeping spin locks" are really just sleeping mutexes (or binary
> > semaphores).
> >
> > 1. Short critical regions are protected by spin_lock_irq(). The maximum
> > value of "short" is therefore bounded by the maximum time we are happy
> > to disable (local) interrupts - ideally ~100us.
> >
> > 2. Longer regions are protected by sleeping mutexes.
> >
> > 3. Algorithms are rearchitected until all of the highly contended locks
> > are of type 1, and only low contention locks are of type 2.
> >
> > This approach has the advantage that we don't need to use a no-preempt
> > count, and test it on exit from every spinlock to see if a preempting
> > interrupt that has caused a need_resched has occurred, since we won't
> > see the interrupt until it's safe to do the preemptive resched.
>
> I agree that this was true in days of yore. But these days the irq
> instructions introduce serialization points and, me thinks, may be much
> more time consuming than the "++, --, if (false)" that a preemption
> count implemtation introduces. Could some one with a knowledge of the
> hardware comment on this?
>
> I am not suggesting that the "++, --, if (false)" is faster than an
> interrupt, but that it is faster than cli, sti. Of course we are
> assuming that there is <stuff> between the cli and the sti as there is
> between the ++ and the -- if (false).
>
The problem with counting scheme is that you can not schedule inside any
spinlock - you have to split them up. Maybe you will have to do that anyway.
But if your RT process never needs more memory - it should be quite safe.
The difference with a sleeping mutex is that it can be made lazier - keep it
in the runlist, there should be very few...
See first patch attempt.
(George, Nigel told me about your idea before I sent the previous mail. So
major influence comes from you. But I do not think that it is equivalent)
/RogerL
Note: changed email...
--------------Boundary-00=_C758GGJYQOG356JFOZI4
Content-Type: text/x-c;
charset="iso-8859-1";
name="patch-2.4.1-preX-rescheduleinspinlock"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="patch-2.4.1-preX-rescheduleinspinlock"
LS0tIC4vbGludXgva2VybmVsL3NjaGVkLmMub3JpZwlTYXQgSmFuIDEzIDE5OjE5OjIwIDIwMDEK
KysrIC4vbGludXgva2Vyb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XJkLCBJUFIpKSAmJgorCQkgLS1saW1pdF9sb29wKTsKKworCWlmIChsaW1pdF9sb29wID09IDAg
JiYgaXJxc3RhdHVzICE9IDApCisJICBwcmludGsoS0VSTl9FUlIgImxvb3AgbGltaXQgcmVhY2hl
ZCBpbiBlbXUxMGssIGlycXN0YXR1cyAleFxuIiwKKwkJIGlycXN0YXR1cyk7CiAKIAlyZXR1cm47
CiB9Ci0K
--------------Boundary-00=_C758GGJYQOG356JFOZI4--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/