From owner-freebsd-threads@FreeBSD.ORG Thu Sep 23 14:25:57 2010 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E640F106564A for ; Thu, 23 Sep 2010 14:25:57 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id B75DE8FC12 for ; Thu, 23 Sep 2010 14:25:57 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 66C1A46C04; Thu, 23 Sep 2010 10:25:57 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 704688A050; Thu, 23 Sep 2010 10:25:56 -0400 (EDT) From: John Baldwin To: freebsd-threads@freebsd.org Date: Thu, 23 Sep 2010 10:06:39 -0400 User-Agent: KMail/1.13.5 (FreeBSD/7.3-CBSD-20100819; KDE/4.4.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201009231006.40019.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Thu, 23 Sep 2010 10:25:56 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: Alexander Churanov Subject: Re: What is the status of thread process-shared synchronization? 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: Thu, 23 Sep 2010 14:25:58 -0000 On Thursday, September 23, 2010 8:19:26 am Alexander Churanov wrote: > Hi folks! > > The FreeBSD 8.1 manual pages state that pthread process-shared > synchronization option is not supported, at least for some primitives. > > 1) Are there any plans to implement this option? > 2) Is anybody working on that? > 3) What are the main obstacles which prevent us from having the option > implemented? > > I am teaching students UNIX-like systems in general and FreeBSD in > particular. I've set them a task on synchronizing processes reading > and writing from a shared-memory cache. But then found that in spite > of PTHREAD_PROCESS_SHARED being available, it is not supported. I've > endeavored to fix POSIX rwlocks by making pthread_rwlock_t a > structure, but then found that POSIX semaphores do not support > process-shared attribute either. I believe POSIX semaphores in 9 do now support PTHREAD_PROCESS_SHARED. David Xu implemented it. He may be able to MFC this to 8-stable. > 4) Do we have any synchronization primitive capable of synchronizing > threads in different processes in FreeBSD? Unfortunately the various POSIX/SYSV primitives do not currently support it in 8. You could implement a shared mutex on top of umtx fairly easily I believe. umtx itself is address-space agnostic (so a umtx object can be shared among processes), and the existing pthread_mutex code can probably be borrowed directly to implement a mutex. I think the biggest obstacle for FreeBSD is changing the definition of pthread_mutex_t, etc. to be structures instead of pointers to dynamically allocated structures. -- John Baldwin