From owner-freebsd-threads@FreeBSD.ORG Mon Dec 8 17:45:46 2003 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 9E06316A4CE for ; Mon, 8 Dec 2003 17:45:46 -0800 (PST) Received: from smtp1.jp.viruscheck.net (smtp1.jp.viruscheck.net [154.33.69.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1643243D2D for ; Mon, 8 Dec 2003 17:45:43 -0800 (PST) (envelope-from bland@freebsd.org) Received: from scan2.jp.viruscheck.net ([154.33.69.37] helo=mail3.jp.viruscheck.net) by smtp1.jp.viruscheck.net with esmtp (Exim 3.36 #1) id 1ATWwY-0001ph-00 for threads@freebsd.org; Tue, 09 Dec 2003 10:45:42 +0900 Received: from [220.220.111.152] (helo=noc.orchid) by mail3.jp.viruscheck.net with esmtp (Exim 3.36 #3) id 1ATWwX-0000LK-00 for threads@FreeBSD.org; Tue, 09 Dec 2003 10:45:41 +0900 Received: from FreeBSD.org (horse.orchid [89.60.10.11]) by noc.orchid (8.12.9p2/8.12.9) with ESMTP id hB91je4v014733 for ; Tue, 9 Dec 2003 10:45:40 +0900 (JST) (envelope-from bland@FreeBSD.org) Message-ID: <3FD52944.40007@FreeBSD.org> Date: Tue, 09 Dec 2003 10:45:40 +0900 From: Alexander Nedotsukov User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: threads@FreeBSD.org Content-Type: multipart/mixed; boundary="------------060707010505080100050504" Subject: typo in my last post 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: Tue, 09 Dec 2003 01:45:46 -0000 This is a multi-part message in MIME format. --------------060707010505080100050504 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Please read thr_mutex.c:mutex_lock_common() as thr_mutex.c:mutex_unlock_common(). I also think it will be good to add this: http://www.opengroup.org/onlinepubs/007904975/functions/pthread_mutex_lock.html Here is a quote: ERRORS ... [EPERM] The current thread does not own the mutex. ... Wich is similar to our: ... [EPERM] The current thread does not hold a lock on mutex. ... And this is what actually happen when mutex just intialized or unlocked. It's vaild but simply owned by no one therefore not by current thread. What I trying to say that current behaviour looks like: ... [EPERM] Mutex hold by another thread. ... See also proposed patch attached. Thanks, Alexander. --------------060707010505080100050504 Content-Type: text/plain; name="libpthread.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="libpthread.patch" cvs server: Diffing . Index: thr_mutex.c =================================================================== RCS file: /home/ncvs/src/lib/libpthread/thread/thr_mutex.c,v retrieving revision 1.44 diff -u -r1.44 thr_mutex.c --- thr_mutex.c 9 Dec 2003 00:52:28 -0000 1.44 +++ thr_mutex.c 9 Dec 2003 01:40:21 -0000 @@ -1001,11 +1001,8 @@ * mutex: */ if ((*m)->m_owner != curthread) - /* - * Return an invalid argument error for no - * owner and a permission error otherwise: - */ - ret = (*m)->m_owner == NULL ? EINVAL : EPERM; + /* We're not own this one */ + ret = EPERM; else if (((*m)->m_type == PTHREAD_MUTEX_RECURSIVE) && ((*m)->m_count > 0)) @@ -1039,11 +1036,8 @@ * mutex: */ if ((*m)->m_owner != curthread) - /* - * Return an invalid argument error for no - * owner and a permission error otherwise: - */ - ret = (*m)->m_owner == NULL ? EINVAL : EPERM; + /* We're not own this one */ + ret = EPERM; else if (((*m)->m_type == PTHREAD_MUTEX_RECURSIVE) && ((*m)->m_count > 0)) @@ -1096,11 +1090,8 @@ * mutex: */ if ((*m)->m_owner != curthread) - /* - * Return an invalid argument error for no - * owner and a permission error otherwise: - */ - ret = (*m)->m_owner == NULL ? EINVAL : EPERM; + /* We're not own this one */ + ret = EPERM; else if (((*m)->m_type == PTHREAD_MUTEX_RECURSIVE) && ((*m)->m_count > 0)) --------------060707010505080100050504--