Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 May 2005 09:41:18 -0700
From:      Maksim Yevmenkin <maksim.yevmenkin@savvis.net>
To:        Norbert Koch <NKoch@demig.de>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: mutual exclusion in vkbd
Message-ID:  <429C93AE.8060509@savvis.net>
In-Reply-To: <000001c565f6$d46b7720$4801a8c0@ws-ew-3.W2KDEMIG>
References:  <000001c565f6$d46b7720$4801a8c0@ws-ew-3.W2KDEMIG>

next in thread | previous in thread | raw e-mail | index | archive | help
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)

and you should be done. its not really required to store interrupt mask 
in softc structure, but this way its less changes to the code.

thanks,
max



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?429C93AE.8060509>