From owner-freebsd-smp@FreeBSD.ORG Thu Dec 15 16:17:45 2005 Return-Path: X-Original-To: freebsd-smp@freebsd.org Delivered-To: freebsd-smp@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 06D9716A41F for ; Thu, 15 Dec 2005 16:17:45 +0000 (GMT) (envelope-from asmrookie@gmail.com) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.204]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2093F43D5E for ; Thu, 15 Dec 2005 16:17:44 +0000 (GMT) (envelope-from asmrookie@gmail.com) Received: by zproxy.gmail.com with SMTP id z6so437977nzd for ; Thu, 15 Dec 2005 08:17:43 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=S2aM5hmNQvr0hvcJXQMb6KBmeFDGLDwUWaG9xbJUjZ4EvjXlBTVbmoM6zrZV4mfaNeQosxVZ/gDL/zC32Jk4cIzDG7xJx8x07dzI6TmH0G5zZzm7k3CI8zUkK2a0XMCXjuRcEhrL27KTpRScY65fll8rGKjk+Gnc2cXbiIcH7Sw= Received: by 10.37.22.8 with SMTP id z8mr2121991nzi; Thu, 15 Dec 2005 08:17:42 -0800 (PST) Received: by 10.36.43.18 with HTTP; Thu, 15 Dec 2005 08:17:42 -0800 (PST) Message-ID: <3bbf2fe10512150817s346d621do@mail.gmail.com> Date: Thu, 15 Dec 2005 08:17:42 -0800 From: rookie To: John Baldwin In-Reply-To: <200512151017.12168.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <1fa17f810512150652h5da6a6a5g3347f841a614689e@mail.gmail.com> <200512151017.12168.jhb@freebsd.org> Cc: freebsd-smp@freebsd.org Subject: Re: Use turnstile to implement sx_lock X-BeenThere: freebsd-smp@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: rookie@gufi.org List-Id: FreeBSD SMP implementation group List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2005 16:17:45 -0000 2005/12/15, John Baldwin : > > 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 rwlo= ck > project. I've sort-of started on this but haven't gotten very far at all= in > my jhb_lock p4 branch. I'm working on the same problem too and I found another solution beacause, in order to mantain a clean design, maybe modifying turnstiles code is not the better idea. If we have a thread trying to slock it just blocks if sx is held in "exclusive mode" by another thread so it's enough a simple turnstile as for other blocking locks and we have nice priorty propagation. The real problem is when we try to xlock. A xlocking thread blocks if sx is held in "shared mode" (even by different owners) so we might mantain a track of every slocking thread (through a tailqueue, a static array or whatever) in order to have a priority propagation for those. I think (I didn't implement yet) it can be done outside the turnstile context so it seems we don't necessary need to modify. Finally, we might consider one thing: turnstile has just one owner while we have (in the slocks) more than one and so what's the real owner? We could use a "head thread" per track which must be treacted carefully (EG: on slocking it we might switch the turnstile owner). What do you think about? Attilio -- Peace can only be achieved by understanding - A. Einstein