From owner-freebsd-threads@FreeBSD.ORG Thu Mar 11 11:28:59 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 8FBF416A4CE for ; Thu, 11 Mar 2004 11:28:59 -0800 (PST) Received: from smtp.des.no (flood.des.no [217.116.83.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5079C43D45 for ; Thu, 11 Mar 2004 11:28:59 -0800 (PST) (envelope-from des@des.no) Received: by smtp.des.no (Pony Express, from userid 666) id 271735310; Thu, 11 Mar 2004 20:28:58 +0100 (CET) Received: from dwp.des.no (des.no [80.203.228.37]) by smtp.des.no (Pony Express) with ESMTP id 8A482530A; Thu, 11 Mar 2004 20:28:47 +0100 (CET) Received: by dwp.des.no (Postfix, from userid 2602) id 060A333CA6; Thu, 11 Mar 2004 20:28:46 +0100 (CET) To: Anders Torger References: <200403111459.11287.torger@ludd.luth.se> <40507287.1040203@he.iki.fi> <200403111616.15668.torger@ludd.luth.se> From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) Date: Thu, 11 Mar 2004 20:28:46 +0100 In-Reply-To: <200403111616.15668.torger@ludd.luth.se> (Anders Torger's message of "Thu, 11 Mar 2004 16:16:15 +0100") Message-ID: User-Agent: Gnus/5.090024 (Oort Gnus v0.24) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on flood.des.no X-Spam-Level: X-Spam-Status: No, hits=0.0 required=5.0 tests=AWL autolearn=no version=2.63 cc: freebsd-threads@freebsd.org Subject: Re: Does PTHREAD_MUTEX_INITIALIZER work? 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: Thu, 11 Mar 2004 19:28:59 -0000 Anders Torger writes: > PTHREAD_MUTEX_INITIALIZER is defined as NULL in 5.2.1 too. I shall > test the software on that platform later though. However, it would > be nice if someone could explain this NULL thing Our pthread_mutex_t is a pointer type, and the pthread_mutex_* functions will automatically create a new mutex with default attributes if the specified mutex is NULL (remember that it is passed by reference, so they can replace NULL with a pointer to the new mutex structure) > (it is not NULL on > other pthread implementations I have looked at). Other implementations may define pthread_mutex_t as a struct, in which case PTHREAD_MUTEX_INITIALIZER corresponds to an initialized, unlocked mutex with default attributes. The advantage of this is that mutexes can be used in places where malloc() calls are prohibited (such as in signal handlers and within malloc() itself). On the other hand, you can't change the size of that struct without breaking binary compatibility. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no