From owner-freebsd-hackers@FreeBSD.ORG Tue May 31 16:41:45 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 72A9C16A41C for ; Tue, 31 May 2005 16:41:45 +0000 (GMT) (envelope-from Maksim.Yevmenkin@savvis.net) Received: from mailgate1b.savvis.net (mailgate1b.savvis.net [216.91.182.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id E53B943D5D for ; Tue, 31 May 2005 16:41:42 +0000 (GMT) (envelope-from Maksim.Yevmenkin@savvis.net) Received: from localhost (localhost.localdomain [127.0.0.1]) by mailgate1b.savvis.net (Postfix) with ESMTP id 34CC03BEE9; Tue, 31 May 2005 11:41:42 -0500 (CDT) Received: from mailgate1b.savvis.net ([127.0.0.1]) by localhost (mailgate1b.savvis.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 24734-01-86; Tue, 31 May 2005 11:41:42 -0500 (CDT) Received: from out001.email.savvis.net (out001.apptix.savvis.net [216.91.32.44]) by mailgate1b.savvis.net (Postfix) with ESMTP id 0827F3BE2D; Tue, 31 May 2005 11:41:42 -0500 (CDT) Received: from s228130hz1ew171.apptix-01.savvis.net ([10.146.4.29]) by out001.email.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Tue, 31 May 2005 11:41:27 -0500 Received: from [10.254.186.111] ([66.35.239.94]) by s228130hz1ew171.apptix-01.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Tue, 31 May 2005 11:41:17 -0500 Message-ID: <429C93AE.8060509@savvis.net> Date: Tue, 31 May 2005 09:41:18 -0700 From: Maksim Yevmenkin User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050404) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Norbert Koch References: <000001c565f6$d46b7720$4801a8c0@ws-ew-3.W2KDEMIG> In-Reply-To: <000001c565f6$d46b7720$4801a8c0@ws-ew-3.W2KDEMIG> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 31 May 2005 16:41:17.0196 (UTC) FILETIME=[90E59CC0:01C565FF] X-Virus-Scanned: amavisd-new at savvis.net Cc: freebsd-hackers@freebsd.org Subject: Re: mutual exclusion in vkbd X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 May 2005 16:41:45 -0000 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