From owner-freebsd-current@FreeBSD.ORG Mon Nov 26 17:48:16 2007 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DB0F16A46C for ; Mon, 26 Nov 2007 17:48:16 +0000 (UTC) (envelope-from darrenr@freebsd.org) Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by mx1.freebsd.org (Postfix) with ESMTP id 578C813C44B for ; Mon, 26 Nov 2007 17:48:15 +0000 (UTC) (envelope-from darrenr@freebsd.org) Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 11BAE5435F; Mon, 26 Nov 2007 12:32:16 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Mon, 26 Nov 2007 12:32:16 -0500 X-Sasl-enc: 3DeHZgYPF6taBwDVrr4nddxJj6Mlo9Pkr7wJrxFE4VEG 1196098335 Received: from [192.168.1.235] (64-142-85-108.dsl.dynamic.sonic.net [64.142.85.108]) by mail.messagingengine.com (Postfix) with ESMTP id 63D9A24FA; Mon, 26 Nov 2007 12:32:15 -0500 (EST) Message-ID: <474B027E.2000801@freebsd.org> Date: Mon, 26 Nov 2007 09:29:34 -0800 From: Darren Reed User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 To: Stephan Uphoff References: <4749BB5B.7040801@elischer.org> <4749BBDE.6000107@elischer.org> <474AE5AE.4020301@freebsd.org> In-Reply-To: <474AE5AE.4020301@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Julian Elischer , FreeBSD Current Subject: Re: rmlock question.. X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Nov 2007 17:48:16 -0000 Stephan Uphoff wrote: > Julian Elischer wrote: >> Julian Elischer wrote: >>> If I make an exclusive rmlock request on an rmlock that has a busy >>> set of readers coming and going, do new readers wait for me to get >>> my turn, or do I have to wait for a moment where there are no more >>> readers before I get a go? >> in fact if the requests are of the order >> >> reader, reader, writer, reader, reader, writer, reader >> >> is the order of evaluation defined? is it preserved? > This is a bit of a tricky question to answer. > ... > So in your example the first writer (W1) will be blocked by the first > two Readers (R1,R2) > but will disable the read fast path and hold the internal mutex. > W1 will block R3,R4,W2,R5 as they all need to acquire the internal mutex. > If R1,R2 release the lock, W1 will become unblocked and eventually > unlock the lock > such releasing the mutex. At this time R3,R4,W2,R5 compete for the > mutex and whoever > wins is next in the locking order. Is there is a chance that so long as there is more than one Reader waiting for a mutex, a Write lock request may never be granted? Given the name "read mostly", is there any favouritism towards Readers vs Writers when competing for the mutex? Or conversely, if there is always a pending Write request that a read is never granted? When R3,R4,W3,R5 compete for the mutex, if R3-5 wins, is the read fast path enabled again? If any of the Readers wins, does this mean that all Readers are dequeued, or only those upto the pending Write? Darren