From owner-freebsd-threads@FreeBSD.ORG Wed Jan 28 08:50:54 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD3DB16A4CE for ; Wed, 28 Jan 2004 08:50:54 -0800 (PST) Received: from telecom.net.et (sparrow.telecom.net.et [213.55.64.38]) by mx1.FreeBSD.org (Postfix) with ESMTP id D0AC143D5A for ; Wed, 28 Jan 2004 08:50:41 -0800 (PST) (envelope-from mtm@identd.net) Received: from [213.55.67.162] (HELO pool-151-200-10-97.res.east.verizon.net) by telecom.net.et (CommuniGate Pro SMTP 3.4.8) with ESMTP-TLS id 35321398; Wed, 28 Jan 2004 19:45:08 +0300 Received: from mobile.acsolutions.com (localhost [127.0.0.1]) ESMTP id i0SGoagn003779; Wed, 28 Jan 2004 19:50:38 +0300 (EAT) (envelope-from mtm@mobile.acsolutions.com) Received: (from mtm@localhost) by mobile.acsolutions.com (8.12.10/8.12.10/Submit) id i0SGoXxZ003778; Wed, 28 Jan 2004 19:50:33 +0300 (EAT) (envelope-from mtm) Date: Wed, 28 Jan 2004 19:50:32 +0300 From: Mike Makonnen To: Daniel Eischen Message-ID: <20040128165031.GA3461@mobile.acsolutions.com> References: <3FD245FF.3040003@melbpc.org.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD/5.2-CURRENT (i386) cc: threads@FreeBSD.org cc: Peter Kostouros Subject: Re: pthread_mutex_trylock() should never block X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jan 2004 16:50:55 -0000 On Sun, Dec 07, 2003 at 01:34:31AM -0500, Daniel Eischen wrote: > > The man page may not mention it, and that may be a bug, but I > think a pthread_mutex_trylock() on a non-recursive mutex is allowed > to return EDEADLK. > > http://www.opengroup.org/onlinepubs/007904975/functions/pthread_mutex_trylock.html > > If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then error > checking shall be provided. If a thread attempts to relock a > mutex that it has already locked, an error shall be returned. > If a thread attempts to unlock a mutex that it has not locked > or a mutex which is unlocked, an error shall be returned. > > ... If you look further down in the spec you will see: The pthread_mutex_trylock() function shall be equivalent to pthread_mutex_lock(), except that if the mutex object referenced by mutex is currently locked (by any thread, including the current thread), the call shall return immediately... Cheers. -- Mike Makonnen | GPG-KEY: http://www.identd.net/~mtm/mtm.asc mtm@identd.net | Fingerprint: 00E8 61BC 0D75 7FFB E4D3 6BF1 B239 D010 3215 D418 mtm@FreeBSD.Org| FreeBSD - Unleash the Daemon !