Date: Wed, 1 Jun 2005 08:08:29 +0200 From: "Norbert Koch" <NKoch@demig.de> To: "Maksim Yevmenkin" <maksim.yevmenkin@savvis.net>, "Alexander Kabaev" <kan@freebsd.org> Cc: freebsd-hackers@freebsd.org Subject: RE: mutual exclusion in vkbd Message-ID: <002701c56670$54ee4980$4801a8c0@ws-ew-3.W2KDEMIG> In-Reply-To: <429CD013.7070809@savvis.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Thank you all. I'll try it. Norbert > -----Original Message----- > From: owner-freebsd-hackers@freebsd.org > [mailto:owner-freebsd-hackers@freebsd.org]On Behalf Of Maksim Yevmenkin > Sent: Tuesday, May 31, 2005 10:59 PM > To: Alexander Kabaev > Cc: Norbert Koch; freebsd-hackers@freebsd.org > Subject: Re: mutual exclusion in vkbd > > > Alexander Kabaev wrote: > > On Tue, May 31, 2005 at 09:41:18AM -0700, Maksim Yevmenkin wrote: > > > >>Norbert, > >> > >> > >>>I am currently trying to backport vkbd to FreeBSD 4. > >> > >>ok > >> > >> > >>>Maksim Yevmenkin uses mtx_lock()/mtx_unlock() for > >>>protecting access to data structures under FreeBSD 5/6 > >>>between the device functions and the kernel thread. > >>> > >>>How should I best do this under FreeBSD 4? > >>> > >>>Would something like splhigh() work in that context? > >>>Or should I use lockmgr with LK_EXCLUSIVE/LK_RELEASE? > >>>Is there any (pseudo)process context inside a kernel task? > >> > >>spltty() is what you probably need to use. you could just adjust the > >>following defines like > >> > >>#define VKBD_LOCK_DECL int > >>#define VKBD_LOCK_INIT(s) /* noop */ > >>#define VKBD_LOCK_DESTROY(s) /* noop */ > >>#define VKBD_LOCK(s) (s)->ks_lock = spltty() > >>#define VKBD_UNLOCK(s) splx((s)->ks_lock) > >>#define VKBD_LOCK_ASSERT(s, w) > >>#define VKBD_SLEEP(s, f, d, t) \ > >> tsleep(&(s)->f, PCATCH | (PZERO + 1), d, t) > > > > The code above will probably crash the kernel in many spectacular and > > unpredictable ways. You will need to save interrupt flags > locally to each > > VKBD_LOCK caller or they will end up restoring each other's flags. > > yes, you are correct. my bad :( thanks for catching this > > max > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?002701c56670$54ee4980$4801a8c0>