From owner-freebsd-threads@FreeBSD.ORG Fri Sep 24 03:48:55 2010 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id 4E0FC106566B; Fri, 24 Sep 2010 03:48:55 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: Daniel Eischen Date: Thu, 23 Sep 2010 23:48:40 -0400 User-Agent: KMail/1.6.2 References: <201009232220.o8NMK3fX011639@freefall.freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Message-Id: <201009232348.45201.jkim@FreeBSD.org> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: threads/150889: PTHREAD_MUTEX_INITIALIZER + pthread_mutex_destroy () == EINVAL 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: Fri, 24 Sep 2010 03:48:56 -0000 On Thursday 23 September 2010 06:44 pm, Daniel Eischen wrote: > You shouldn't have to call pthread_mutex_init() on a mutex > initialized with PTHREAD_MUTEX_INITIALIZER. Our implementation > should auto initialize the mutex when it is first used; if it > doesn't, I think that is a bug. Ah, I see. I verified that libthr does it correctly. However, that's a hack and it is far from real static allocation although it should work pretty well in reality, IMHO. More over, it will have a side-effect, i.e., any destroyed mutex may be resurrected if it is used again. POSIX seems to say it should return EINVAL when it happens. :-( > You _do have_ to lock the mutex before calling a condition > wait, however. This is a POSIX requirement. Yes, understood. Thanks, Jung-uk Kim