From owner-freebsd-current@FreeBSD.ORG Tue Nov 30 05:48:11 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0264E106564A for ; Tue, 30 Nov 2010 05:48:11 +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 E7B218FC16 for ; Tue, 30 Nov 2010 05:48:10 +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 oAU5m979027788 for ; Tue, 30 Nov 2010 05:48:10 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4CF4901B.8030108@freebsd.org> Date: Tue, 30 Nov 2010 13:48:11 +0800 From: David Xu User-Agent: Thunderbird 2.0.0.24 (X11/20100630) MIME-Version: 1.0 To: FreeBSD Current Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: CFT: patch for process shared pthread objects X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2010 05:48:11 -0000 Hi, I finally have worked out first patch to make our pthread library support process shared pthread objects: http://people.freebsd.org/~davidxu/pshared/patch1.diff Many changes are related to redesigned pthread condition variable, these changes try to eliminate extra context switch when pthread_cond_signal is called which could reduce performance. There are two parts in the condition variable implementation. A pure usermode condition variable and kernel-based condition variable. All priority protected, inherited mutexs and process shared mutex will use kernel base condition variable, for a normal mutex, the usermode condition variable is used. Both user-mode and kernel-based try to migrate a thread from condition variable wait queue to mutex wait queue. Another added feature is robust mutex support, http://www.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_setrobust.html Which I think is mostly used for process-shared mutex. In the patch, if mutex attribute is robust, the thread library also uses kernel base condition variable which does not have internal lock in userland. Regards, David Xu