From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 15 15:16:50 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 86F9B16A41F for ; Thu, 15 Dec 2005 15:16:50 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6936D43D62 for ; Thu, 15 Dec 2005 15:16:49 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.5b3) with ESMTP id 3865607 for multiple; Thu, 15 Dec 2005 10:14:47 -0500 Received: from localhost (john@localhost [127.0.0.1]) by server.baldwin.cx (8.13.1/8.13.1) with ESMTP id jBFFGfhQ069623; Thu, 15 Dec 2005 10:16:41 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Thu, 15 Dec 2005 10:17:11 -0500 User-Agent: KMail/1.8.2 References: <1fa17f810512150652h5da6a6a5g3347f841a614689e@mail.gmail.com> In-Reply-To: <1fa17f810512150652h5da6a6a5g3347f841a614689e@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200512151017.12168.jhb@freebsd.org> X-Virus-Scanned: ClamAV version 0.87.1, clamav-milter version 0.87 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.8 required=4.2 tests=ALL_TRUSTED autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on server.baldwin.cx X-Server: High Performance Mail Server - http://surgemail.com r=1653887525 Cc: prime Subject: Re: Use turnstile to implement sx_lock 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: Thu, 15 Dec 2005 15:16:50 -0000 On Thursday 15 December 2005 09:52 am, prime wrote: > hi hackers, > I want to use turnstile to implement sx_lock( or read/write lock),but > find that there is a big obstacle, > ONE sx_lock needs TWO queues to put waiters on,one for readers and the > other one for writers,but ONE turnstile can only supply ONE queue,and ONE > sx_lock can only get ONE turnstile. > > I read opensolaris' rw_lock implementation and find that its turnstile > has TWO queues which is different from FreeBSD's turnstile. > > Are there any good ideas to bypass the obstacle? Thanks very much. You have to add a second queue to the turnstile and make priority propagation still work, etc. Mutexes would just use the exclusive queue all the time whereas rwlocks would use both queues. This is the hard part of the rwlock project. I've sort-of started on this but haven't gotten very far at all in my jhb_lock p4 branch. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org