Date: Fri, 19 Oct 2001 14:53:38 -0700 (PDT) From: John Baldwin <jhb@FreeBSD.org> To: Brett Glass <brett@lariat.org> Cc: Dag-Erling Smorgrav <des@ofug.org>, chat@FreeBSD.ORG Subject: Re: Breaking news: FreeBSD is "considering implementing a preemp Message-ID: <XFMail.011019145338.jhb@FreeBSD.org> In-Reply-To: <4.3.2.7.2.20011018232356.04601a40@localhost>
next in thread | previous in thread | raw e-mail | index | archive | help
On 19-Oct-01 Brett Glass wrote: > At 11:13 PM 10/16/2001, John Baldwin wrote: > >>The only remaining trick is >>to not preempt during critical sections which are already marked by our >>critical_enter/exit API. > > That's the hardest part: recognizing, in existing code, what's a > critical section. It may be non-obvious what will leave the kernel data > structures inconsistent in some subtle way -- especially if it involves > data values that should not be present at the same time rather than > dangling pointers. Actually this isn't all that hard. You see, we already mark them iwth the critical_enter/exit API I described. The trick I was referring to was the code in critical_exit() to check the PS_OWEPREEMPT flag when critnest gets down to 0. The only places that (so far) have needed an additional explicit critical section in current (it is already implicitly guaranteed in the non-preemption case right now by having interrupts disabled) are the fast interrupt handlers. More specifically, hardclock(), since it can switch to softclock()'s software interrupt thread. However, this is really not all that hard to do. I think I had it running on my laptop at Usenix in about a day, and fixed that missing critical sectoin a couple of days later which was enough for UP x86 and most of UP alpha in only a couple of days work. Since spin mutexes already contain a critical section, most of the critical sections are already protected in -current. Having locks on data (i.e. mutexes, sx locks, etc.) are what prevent the corruption you describe, and that really isn't that difficult. > --Brett -- 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.011019145338.jhb>