Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Oct 2001 22:13:47 -0700 (PDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Brett Glass <brett@lariat.org>
Cc:        chat@FreeBSD.ORG, Dag-Erling Smorgrav <des@ofug.org>
Subject:   Re: Breaking news: FreeBSD is "considering implementing a preemp
Message-ID:  <XFMail.011016221347.jhb@FreeBSD.org>
In-Reply-To: <4.3.2.7.2.20011017120858.046a58a0@localhost>

next in thread | previous in thread | raw e-mail | index | archive | help

On 17-Oct-01 Brett Glass wrote:
> At 09:40 AM 10/16/2001, Dag-Erling Smorgrav wrote:
>   
>>Robert Love is writing a patch to make the Linux kernel preemptible,
>>and has some interesting ideas about FreeBSD:
>>
>>http://kerneltrap.com/article.php?sid=328&mode=thread&order=0
> 
> Kernel pre-emption is tough to retrofit into a kernel, but not hard
> to put in if you're writing one from scratch. SVS' "Integrity"
> (http://www.ghs.com/products/rtos/integrity.html) has had it for
> quite some time. The RTOS never turns off interrupts, though it does 
> ignore those that come in while a previous interrupt from the same
> source is being handled.

Actually, it's not that hard at all with interrupt threads already in place in
-current.  You just do a simple check in setrunqueue() to see if you should
switch to the new thread/process when it's put on the runq (i.e. is its
priority higher than your current thread/process.)  The only remaining trick is
to not preempt during critical sections which are already marked by our
critical_enter/exit API.  Basically, if we are in a critical section, then
setrunqueue() sets a flag in the current thread rather than switching, and when
we call critical_exit() to exit the critical section we switch if that flag is
set (i.e. we delay the preemption until we exit the critical section).  It
actualy is fairly simple, and it removes things like the MTX_NOSWITCH flag and
the SWI_SWITCH/SWI_NOSWITCH flags thus simplifying some interfaces.

-- 

John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.011016221347.jhb>