From owner-svn-src-user@FreeBSD.ORG Wed Nov 17 01:52:44 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D78121065670; Wed, 17 Nov 2010 01:52:44 +0000 (UTC) (envelope-from davidxu@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id C53938FC13; Wed, 17 Nov 2010 01:52:44 +0000 (UTC) Received: from xyf.my.dom (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id oAH1qgcZ039291; Wed, 17 Nov 2010 01:52:43 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4CE3A5EE.9060803@freebsd.org> Date: Wed, 17 Nov 2010 09:52:46 +0000 From: David Xu User-Agent: Thunderbird 2.0.0.24 (X11/20100630) MIME-Version: 1.0 To: Jilles Tjoelker References: <201011120934.oAC9YLN1002510@svn.freebsd.org> <20101116222621.GA44741@stack.nl> In-Reply-To: <20101116222621.GA44741@stack.nl> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r215170 - in user/davidxu/libthr/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Nov 2010 01:52:44 -0000 Jilles Tjoelker wrote: > On Fri, Nov 12, 2010 at 09:34:21AM +0000, David Xu wrote: >> Author: davidxu >> Date: Fri Nov 12 09:34:21 2010 >> New Revision: 215170 >> URL: http://svn.freebsd.org/changeset/base/215170 > >> Log: >> Limit total number of robust mutexes a process can hold. > > I think a per thread limit is better as it is more predictable. If the > limit is exceeded, pthread_mutex_lock() will fail. per-thread limit is uncertain. I don't know if I should let pthread_mutex_lock fail, because I saw so much code do not check error code, unlike java, C programmer tends to ignore error code, while java can throw exception in abnormal case, force you to handle it. I even want to change default mutex from error-check to normal. > >> [...] >> + error = msleep(&max_robust_per_proc, >> + &max_robust_lock, 0, "maxrob", 0); > > I think a PCATCH flag was intended here. > > If you want to do it this way, it needs to wake up if another thread in > the process unlocks something. > Good catch. > If one thread uses up max_robust_per_proc, it is stuck forever. It is > also possible though rare that this wait forms a cycle with lock waits. > Yes