From owner-freebsd-threads@FreeBSD.ORG Tue Jan 25 16:09:06 2011 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5CAB106564A; Tue, 25 Jan 2011 16:09:06 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id 8C5418FC18; Tue, 25 Jan 2011 16:09:06 +0000 (UTC) Received: by gxk8 with SMTP id 8so1852639gxk.13 for ; Tue, 25 Jan 2011 08:09:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=2aXX9jewzG7VifrqCoglnutMxEuQVN7iaSJKO70ZAz0=; b=iq1qnhRk2ohkG116NAV0AREr4AWMSmqpyxPQ/NlTk4vX7kXn4ncUc0WgLxuVOflDgV RlffZoC/V45sNX/NidA+mzYVV037ixP9DLTyKyvFyhgcuZfVHEOvU78QgHPSnObsAFWq gAdXN0Np/igTzvMMoctFdJyTjZW9P1Vq3gRRo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=ElKyXpt7vKeAo5rn/+PifEyPCzK3elLoPH9/MIUuTeRWqdw5WajGAP0cc9/tErQSyN zk+Qckr7E15nJoSEOm3kPKc+Q7pYX3JYHm6AhfdQZrIcOgNY3L4Jbg6qXQJWrSkgIHw+ wqFRCr+I75sSxZNYrd3d01WlIzlWauxxp+lzI= MIME-Version: 1.0 Received: by 10.100.136.2 with SMTP id j2mr496656and.139.1295970007059; Tue, 25 Jan 2011 07:40:07 -0800 (PST) Sender: asmrookie@gmail.com Received: by 10.236.108.15 with HTTP; Tue, 25 Jan 2011 07:40:07 -0800 (PST) In-Reply-To: <201101241604.21451.jhb@freebsd.org> References: <201101241604.21451.jhb@freebsd.org> Date: Tue, 25 Jan 2011 16:40:07 +0100 X-Google-Sender-Auth: NhRAtb2GKWjOaOmygdSrDl04aBo Message-ID: From: Attilio Rao To: John Baldwin Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: threads@freebsd.org, David Xu Subject: Re: Try upgrades and downgrades for POSIX rwlocks X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jan 2011 16:09:07 -0000 2011/1/24 John Baldwin : > Does anyone know if there is a de facto or proposed standard for supporti= ng > upgrades and downgrades in POSIX rwlocks? =C2=A0IBM seems to support some= thing > rather gross where a wrlock() will succeed if the only shared lock is hel= d by > the current thread. =C2=A0But then the thread holds both a read and write= lock, and > it has to call unlock twice, the first to drop the write lock, the second= to > drop the read lock. =C2=A0If we were to add support for upgrades and down= grades I > would prefer something more along the lines of our in-kernel APIs where t= here > are try_upgrade() and downgrade() operations that convert a given lock be= tween > states. I'd support us adopting the same semantic rwlock in kernel space have. An alternative semantic would be what lockmgrs do: - try to upgrade - if failed (more than one shared owner then): * drop our shared lock * try a normal exclusive acquisition That seems like more linear, even if I'm very much more in favor of not having something like that (infact, removing LK_UPGRADE is one of my personal target, as such operation can be implemented in consumers themselves as well, if they want). Attilio --=20 Peace can only be achieved by understanding - A. Einstein