From owner-freebsd-threads@FreeBSD.ORG Mon Dec 21 07:45:46 2009 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 4A2B5106566B for ; Mon, 21 Dec 2009 07:45:46 +0000 (UTC) (envelope-from leonleon77@gmail.com) Received: from mail-iw0-f198.google.com (mail-iw0-f198.google.com [209.85.223.198]) by mx1.freebsd.org (Postfix) with ESMTP id D61C18FC2A for ; Mon, 21 Dec 2009 07:45:45 +0000 (UTC) Received: by iwn36 with SMTP id 36so3434120iwn.3 for ; Sun, 20 Dec 2009 23:45:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=h2k1grUa/Qy/4PHaDMvn0R5agdRrAFKjYxgDsbYYbK0=; b=clWJ6sAujsCp/5lTNWXpkt4F4ucgV8s3UIP0HZh4i6acXmlJMpkzLNUFXlmz87ShQw kgxfken0a9+OQVvAFCP6pbafUYWVzR1vRkGz+JpgbWitkfD7HgS4gqtcbz5eD4Q3jdDT SOupnAkZavKpGEVGxtRxePsKh/yrrsC2mCloI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=xAcj5hDPAggBmV8Oa0h/tg6Ubt1DzUAnyNBO064PD/F54j6jbI0Rr90WcHAZM9f4Ol AYeY/Z925IDBkCKJHeis2chUpa+Szs8NsRBjToBA7irJxOSmN3m/i1Wciqi48nVMFhmW vxqQGNL0dTU4veNUb+mrsyR5VWgTQLjZgic1o= MIME-Version: 1.0 Received: by 10.231.167.212 with SMTP id r20mr99076iby.7.1261379713313; Sun, 20 Dec 2009 23:15:13 -0800 (PST) Date: Mon, 21 Dec 2009 18:15:13 +1100 Message-ID: <26d2cb010912202315g574353d9g872643d1717f4f86@mail.gmail.com> From: leon zadorin To: freebsd-threads@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: disable threads when recompiling libc 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: Mon, 21 Dec 2009 07:45:46 -0000 Hi, is it possible to configure libc to be recompiled in a single-threaded model only (i.e. disable any additional overhead for handling thread-safety). Basically what I'd like to do is to build a separate non-multithreaded copy of libc and use it with the rest of "single threaded environment": recompiled gcc (./configure --disable-threads), etc. c++ boost libs in non-multithreaded mode and so on I would like to see if there are any additional performance-benefits to this (my program does not need to be multi-threaded). I think compiler itself can produce more optimisations (various speculative loads et al) if it is building code for single-threaded model only... I wonder if there are also "single-threaded" performance benefits to libc et al ? From owner-freebsd-threads@FreeBSD.ORG Mon Dec 21 09:18:05 2009 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 4BBC61065670 for ; Mon, 21 Dec 2009 09:18:05 +0000 (UTC) (envelope-from gary.jennejohn@freenet.de) Received: from mout2.freenet.de (mout2.freenet.de [IPv6:2001:748:100:40::2:4]) by mx1.freebsd.org (Postfix) with ESMTP id D712B8FC36 for ; Mon, 21 Dec 2009 09:18:04 +0000 (UTC) Received: from [195.4.92.27] (helo=17.mx.freenet.de) by mout2.freenet.de with esmtpa (ID gary.jennejohn@freenet.de) (port 25) (Exim 4.70 #1) id 1NMeOx-0000G1-KC; Mon, 21 Dec 2009 10:18:03 +0100 Received: from p57ae0045.dip0.t-ipconnect.de ([87.174.0.69]:61499 helo=ernst.jennejohn.org) by 17.mx.freenet.de with esmtpa (ID gary.jennejohn@freenet.de) (port 25) (Exim 4.69 #94) id 1NMeOx-0005De-D5; Mon, 21 Dec 2009 10:18:03 +0100 Date: Mon, 21 Dec 2009 10:18:02 +0100 From: Gary Jennejohn To: leon zadorin Message-ID: <20091221101802.579f6179@ernst.jennejohn.org> In-Reply-To: <26d2cb010912202315g574353d9g872643d1717f4f86@mail.gmail.com> References: <26d2cb010912202315g574353d9g872643d1717f4f86@mail.gmail.com> X-Mailer: Claws Mail 3.7.3 (GTK+ 2.16.2; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: disable threads when recompiling libc X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: gary.jennejohn@freenet.de List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Dec 2009 09:18:05 -0000 On Mon, 21 Dec 2009 18:15:13 +1100 leon zadorin wrote: > is it possible to configure libc to be recompiled in a single-threaded > model only (i.e. disable any additional overhead for handling > thread-safety). > There doesn't seem to be any simple way to do this. libc uses pthread.h and PTHREAD macros all over the place. However, libc routines seem to test __isthreaded to avoid unnecessary calls to thread operations. --- Gary Jennejohn From owner-freebsd-threads@FreeBSD.ORG Mon Dec 21 11:07:05 2009 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 D00EE10656A7 for ; Mon, 21 Dec 2009 11:07:05 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BE0498FC13 for ; Mon, 21 Dec 2009 11:07:05 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nBLB75qm004235 for ; Mon, 21 Dec 2009 11:07:05 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id nBLB75Nk004233 for freebsd-threads@FreeBSD.org; Mon, 21 Dec 2009 11:07:05 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 21 Dec 2009 11:07:05 GMT Message-Id: <200912211107.nBLB75Nk004233@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-threads@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-threads@FreeBSD.org 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: Mon, 21 Dec 2009 11:07:06 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o threa/141721 threads rtprio(1): (id|rt)prio priority resets when new thread o threa/141198 threads [libc] src/lib/libc/stdio does not properly initialize o threa/136345 threads Recursive read rwlocks in thread A cause deadlock with o threa/135673 threads databases/mysql50-server - MySQL query lock-ups on 7.2 p threa/135462 threads [PATCH] _thread_cleanupspecific() doesn't handle delet o threa/133734 threads 32 bit libthr failing pthread_create() o threa/128922 threads threads hang with xorg running o threa/127225 threads bug in lib/libthr/thread/thr_init.c o threa/122923 threads 'nice' does not prevent background process from steali o threa/121336 threads lang/neko threading ok on UP, broken on SMP (FreeBSD 7 o threa/118715 threads kse problem o threa/116668 threads can no longer use jdk15 with libthr on -stable SMP o threa/116181 threads /dev/io-related io access permissions are not propagat o threa/115211 threads pthread_atfork misbehaves in initial thread o threa/110636 threads [request] gdb(1): using gdb with multi thread applicat o threa/110306 threads apache 2.0 segmentation violation when calling gethost o threa/103975 threads Implicit loading/unloading of libpthread.so may crash o threa/101323 threads [patch] fork(2) in threaded programs broken. s threa/100815 threads FBSD 5.5 broke nanosleep in libc_r s threa/94467 threads send(), sendto() and sendmsg() are not correct in libc s threa/84483 threads problems with devel/nspr and -lc_r on 4.x o threa/83914 threads [libc] popen() doesn't work in static threaded program o threa/80992 threads abort() sometimes not caught by gdb depending on threa o threa/80435 threads panic on high loads o threa/79887 threads [patch] freopen() isn't thread-safe o threa/79683 threads svctcp_create() fails if multiple threads call at the s threa/76694 threads fork cause hang in dup()/close() function in child (-l s threa/76690 threads fork hang in child for -lc_r o threa/75374 threads pthread_kill() ignores SA_SIGINFO flag o threa/75273 threads FBSD 5.3 libpthread (KSE) bug o threa/72953 threads fork() unblocks blocked signals w/o PTHREAD_SCOPE_SYST o threa/70975 threads [sysvipc] unexpected and unreliable behaviour when usi s threa/69020 threads pthreads library leaks _gc_mutex s threa/49087 threads Signals lost in programs linked with libc_r s threa/48856 threads Setting SIGCHLD to SIG_IGN still leaves zombies under s threa/40671 threads pthread_cancel doesn't remove thread from condition qu s threa/39922 threads [threads] [patch] Threaded applications executed with s threa/37676 threads libc_r: msgsnd(), msgrcv(), pread(), pwrite() need wra s threa/34536 threads accept() blocks other threads s threa/32295 threads [libc_r] [patch] pthread(3) dont dequeue signals s threa/30464 threads pthread mutex attributes -- pshared s threa/24632 threads libc_r delicate deviation from libc in handling SIGCHL s threa/24472 threads libc_r does not honor SO_SNDTIMEO/SO_RCVTIMEO socket o 43 problems total. From owner-freebsd-threads@FreeBSD.ORG Mon Dec 21 15:18:09 2009 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 B00F11065695 for ; Mon, 21 Dec 2009 15:18:09 +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 853A78FC16 for ; Mon, 21 Dec 2009 15:18:09 +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 4314346B03; Mon, 21 Dec 2009 10:18:09 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 2AA088A01F; Mon, 21 Dec 2009 10:18:08 -0500 (EST) From: John Baldwin To: freebsd-threads@freebsd.org Date: Mon, 21 Dec 2009 10:09:44 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20091103; KDE/4.3.1; amd64; ; ) References: <26d2cb010912202315g574353d9g872643d1717f4f86@mail.gmail.com> In-Reply-To: <26d2cb010912202315g574353d9g872643d1717f4f86@mail.gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912211009.44660.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Mon, 21 Dec 2009 10:18:08 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: Subject: Re: disable threads when recompiling libc 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: Mon, 21 Dec 2009 15:18:09 -0000 On Monday 21 December 2009 2:15:13 am leon zadorin wrote: > Hi, > > is it possible to configure libc to be recompiled in a single-threaded > model only (i.e. disable any additional overhead for handling > thread-safety). > > Basically what I'd like to do is to build a separate non-multithreaded > copy of libc and use it with the rest of "single threaded > environment": > > recompiled gcc (./configure --disable-threads), etc. > c++ boost libs in non-multithreaded mode and so on > > I would like to see if there are any additional performance-benefits > to this (my program does not need to be multi-threaded). > > I think compiler itself can produce more optimisations (various > speculative loads et al) if it is building code for single-threaded > model only... I wonder if there are also "single-threaded" performance > benefits to libc et al ? libc already conditionalizes all the extra multi-thread protection on __isthreaded which only gets set to 1 the first time pthread_create() is invoked, so all you would be able to test is removing several 'if (__isthreaded)' tests. You could perhaps make use of this to build a test libc though by #defining __isthreaded to 0 and relying on the compiler to eliminate all the conditional threading code as dead code. -- John Baldwin From owner-freebsd-threads@FreeBSD.ORG Mon Dec 21 15:19:10 2009 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 8CAAB1065670 for ; Mon, 21 Dec 2009 15:19:10 +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 6197E8FC2C for ; Mon, 21 Dec 2009 15:19:10 +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 1F62846B23; Mon, 21 Dec 2009 10:19:10 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 783BF8A01B; Mon, 21 Dec 2009 10:19:09 -0500 (EST) From: John Baldwin To: freebsd-threads@freebsd.org Date: Mon, 21 Dec 2009 10:09:44 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20091103; KDE/4.3.1; amd64; ; ) References: <26d2cb010912202315g574353d9g872643d1717f4f86@mail.gmail.com> In-Reply-To: <26d2cb010912202315g574353d9g872643d1717f4f86@mail.gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912211009.44660.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Mon, 21 Dec 2009 10:19:09 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: Subject: Re: disable threads when recompiling libc 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: Mon, 21 Dec 2009 15:19:10 -0000 On Monday 21 December 2009 2:15:13 am leon zadorin wrote: > Hi, > > is it possible to configure libc to be recompiled in a single-threaded > model only (i.e. disable any additional overhead for handling > thread-safety). > > Basically what I'd like to do is to build a separate non-multithreaded > copy of libc and use it with the rest of "single threaded > environment": > > recompiled gcc (./configure --disable-threads), etc. > c++ boost libs in non-multithreaded mode and so on > > I would like to see if there are any additional performance-benefits > to this (my program does not need to be multi-threaded). > > I think compiler itself can produce more optimisations (various > speculative loads et al) if it is building code for single-threaded > model only... I wonder if there are also "single-threaded" performance > benefits to libc et al ? libc already conditionalizes all the extra multi-thread protection on __isthreaded which only gets set to 1 the first time pthread_create() is invoked, so all you would be able to test is removing several 'if (__isthreaded)' tests. You could perhaps make use of this to build a test libc though by #defining __isthreaded to 0 and relying on the compiler to eliminate all the conditional threading code as dead code. -- John Baldwin From owner-freebsd-threads@FreeBSD.ORG Wed Dec 23 01:49:55 2009 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C715106566C for ; Wed, 23 Dec 2009 01:49:55 +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 D94758FC0A for ; Wed, 23 Dec 2009 01:49:54 +0000 (UTC) Received: from apple.my.domain (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nBN1nrvx073625 for ; Wed, 23 Dec 2009 01:49:54 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4B317741.8080004@freebsd.org> Date: Wed, 23 Dec 2009 09:49:53 +0800 From: David Xu User-Agent: Thunderbird 2.0.0.9 (X11/20080612) MIME-Version: 1.0 To: threads@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: first patch for process-shared semaphore 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: Wed, 23 Dec 2009 01:49:55 -0000 This is my first attempt to make process-shared mutex work, this means you can mmap(MAP_SHARED) a memory area, and put semaphore there, or you can sem_open a named semaphore, and just use it between processes, the named semaphore uses file system and mmap(), directory /tmp/.semaphore is used as IPC directory, any named semaphore locates in the directory. old semaphore implementation still exists to make it binary compatible, it uses symbol version. http://people.freebsd.org/~davidxu/patch/shared_semaphore_1.patch David Xu From owner-freebsd-threads@FreeBSD.ORG Wed Dec 23 13:17:43 2009 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F22B0106566C; Wed, 23 Dec 2009 13:17:43 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.25]) by mx1.freebsd.org (Postfix) with ESMTP id 910468FC1C; Wed, 23 Dec 2009 13:17:43 +0000 (UTC) Received: by qw-out-2122.google.com with SMTP id 9so1540915qwb.7 for ; Wed, 23 Dec 2009 05:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type; bh=anrjBSjdBOQ4Qo019QSy5PYeB4P2SXf8/H9VnkzUybs=; b=T5vA7SMuzzf8RNChtQ57TWc+kwFZl1U4BxPSixM6Mwgw6ihrT6LLJNrdjYkgl+n/Y1 S5nxETij3fCbcioxBhAhPGI4kjlQKGYh0Af68jMtHK1Ay1t9Mc5IS/6Sepw8GMOwo6ob Se8fU7plQZ4ClfodI4aacdCGiAzvRv7vPx0tk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=UUEPEfzlkjx9XsRDgltoEt5SfMdsnmDeOnnJ1gVqqkenP5BEZ8gZQfiqlvRTN2PqFQ 73OZ9u2Un9l6aW0NRGNbckzwL0f6rSPOWmNAEo3yrhzuNqWzE1l6z1vGofNlQKkySmWf jc7pFj4iYg7CkSvdHYDOoSdi9WGju/o8Ty9Rc= Received: by 10.224.51.76 with SMTP id c12mr5188646qag.363.1261572435608; Wed, 23 Dec 2009 04:47:15 -0800 (PST) Received: from kan.dnsalias.net (c-24-91-218-112.hsd1.ma.comcast.net [24.91.218.112]) by mx.google.com with ESMTPS id 26sm20447456qwa.10.2009.12.23.04.47.12 (version=SSLv3 cipher=RC4-MD5); Wed, 23 Dec 2009 04:47:13 -0800 (PST) Date: Wed, 23 Dec 2009 07:47:07 -0500 From: Alexander Kabaev To: David Xu Message-ID: <20091223074707.2a7ca9d6@kan.dnsalias.net> In-Reply-To: <4B317741.8080004@freebsd.org> References: <4B317741.8080004@freebsd.org> X-Mailer: Claws Mail 3.7.3 (GTK+ 2.18.5; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/vz9bE1U_Wrr212QsM0UsFxx"; protocol="application/pgp-signature" Cc: threads@freebsd.org Subject: Re: first patch for process-shared semaphore 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: Wed, 23 Dec 2009 13:17:44 -0000 --Sig_/vz9bE1U_Wrr212QsM0UsFxx Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Wed, 23 Dec 2009 09:49:53 +0800 David Xu wrote: > This is my first attempt to make process-shared mutex work, this means > you can mmap(MAP_SHARED) a memory area, and put semaphore there, > or you can sem_open a named semaphore, and just use it between > processes, the named semaphore uses file system and mmap(), directory=20 > /tmp/.semaphore is used as IPC directory, any named semaphore > locates in the directory. old semaphore implementation still exists > to make it binary compatible, it uses symbol version. >=20 > http://people.freebsd.org/~davidxu/patch/shared_semaphore_1.patch >=20 >=20 > David Xu >=20 > _______________________________________________ > freebsd-threads@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-threads > To unsubscribe, send any mail to > "freebsd-threads-unsubscribe@freebsd.org" Hi, is libthr really required for semaphores? Semaphore API seem orthogonal to pthreads. None of the man pages on OpenGroup size indicate where these belong, but they put sem_open & friends into REALTIME group and Linux has them in librt. --=20 Alexander Kabaev --Sig_/vz9bE1U_Wrr212QsM0UsFxx Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) iD8DBQFLMhFPQ6z1jMm+XZYRAgwgAJ9O5X+csnvgT6dr7aBHBEcsKom0fwCgpsSa dSJqIqMI9Fr50JqB0WdpiWw= =tnF2 -----END PGP SIGNATURE----- --Sig_/vz9bE1U_Wrr212QsM0UsFxx-- From owner-freebsd-threads@FreeBSD.ORG Wed Dec 23 14:38:38 2009 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4BBFD106566C; Wed, 23 Dec 2009 14:38:38 +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 1EC488FC1A; Wed, 23 Dec 2009 14:38:38 +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 C545C46B23; Wed, 23 Dec 2009 09:38:37 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id F03BA8A01F; Wed, 23 Dec 2009 09:38:36 -0500 (EST) From: John Baldwin To: freebsd-threads@freebsd.org Date: Wed, 23 Dec 2009 09:36:35 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20091103; KDE/4.3.1; amd64; ; ) References: <4B317741.8080004@freebsd.org> In-Reply-To: <4B317741.8080004@freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912230936.35998.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Wed, 23 Dec 2009 09:38:37 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: threads@freebsd.org, David Xu Subject: Re: first patch for process-shared semaphore 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: Wed, 23 Dec 2009 14:38:38 -0000 On Tuesday 22 December 2009 8:49:53 pm David Xu wrote: > This is my first attempt to make process-shared mutex work, this means > you can mmap(MAP_SHARED) a memory area, and put semaphore there, > or you can sem_open a named semaphore, and just use it between > processes, the named semaphore uses file system and mmap(), directory > /tmp/.semaphore is used as IPC directory, any named semaphore > locates in the directory. old semaphore implementation still exists > to make it binary compatible, it uses symbol version. > > http://people.freebsd.org/~davidxu/patch/shared_semaphore_1.patch I would suggest that you leave named semaphores as they currently exist and follow this approach instead: 1) Named semaphores use ksem_*() still. 2) sem_init/sem_destroy operate on UTMX-backed semaphores identical to the ones used in the current libthr code. The semid_t structure now becomes the full structure that libthr currently allocates with a flag to indicate if it is a "system" semaphore or otherwise. The pshared flag passed to sem_init() can be used to set the sharing properties of the UMTX. 3) All of sem_init/sem_destroy is just in libc. Just move the libthr implementation bits into libc. -- John Baldwin From owner-freebsd-threads@FreeBSD.ORG Wed Dec 23 14:38:38 2009 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 4BBFD106566C; Wed, 23 Dec 2009 14:38:38 +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 1EC488FC1A; Wed, 23 Dec 2009 14:38:38 +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 C545C46B23; Wed, 23 Dec 2009 09:38:37 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id F03BA8A01F; Wed, 23 Dec 2009 09:38:36 -0500 (EST) From: John Baldwin To: freebsd-threads@freebsd.org Date: Wed, 23 Dec 2009 09:36:35 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20091103; KDE/4.3.1; amd64; ; ) References: <4B317741.8080004@freebsd.org> In-Reply-To: <4B317741.8080004@freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912230936.35998.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Wed, 23 Dec 2009 09:38:37 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: threads@freebsd.org, David Xu Subject: Re: first patch for process-shared semaphore 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: Wed, 23 Dec 2009 14:38:38 -0000 On Tuesday 22 December 2009 8:49:53 pm David Xu wrote: > This is my first attempt to make process-shared mutex work, this means > you can mmap(MAP_SHARED) a memory area, and put semaphore there, > or you can sem_open a named semaphore, and just use it between > processes, the named semaphore uses file system and mmap(), directory > /tmp/.semaphore is used as IPC directory, any named semaphore > locates in the directory. old semaphore implementation still exists > to make it binary compatible, it uses symbol version. > > http://people.freebsd.org/~davidxu/patch/shared_semaphore_1.patch I would suggest that you leave named semaphores as they currently exist and follow this approach instead: 1) Named semaphores use ksem_*() still. 2) sem_init/sem_destroy operate on UTMX-backed semaphores identical to the ones used in the current libthr code. The semid_t structure now becomes the full structure that libthr currently allocates with a flag to indicate if it is a "system" semaphore or otherwise. The pshared flag passed to sem_init() can be used to set the sharing properties of the UMTX. 3) All of sem_init/sem_destroy is just in libc. Just move the libthr implementation bits into libc. -- John Baldwin From owner-freebsd-threads@FreeBSD.ORG Thu Dec 24 01:20:30 2009 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CEF7A106566B; Thu, 24 Dec 2009 01:20:30 +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 BD53A8FC16; Thu, 24 Dec 2009 01:20:30 +0000 (UTC) Received: from apple.my.domain (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nBO1KSg6001520; Thu, 24 Dec 2009 01:20:29 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4B32C1DC.9080308@freebsd.org> Date: Thu, 24 Dec 2009 09:20:28 +0800 From: David Xu User-Agent: Thunderbird 2.0.0.9 (X11/20080612) MIME-Version: 1.0 To: John Baldwin References: <4B317741.8080004@freebsd.org> <200912230936.35998.jhb@freebsd.org> In-Reply-To: <200912230936.35998.jhb@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: threads@freebsd.org, freebsd-threads@freebsd.org Subject: Re: first patch for process-shared semaphore 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, 24 Dec 2009 01:20:30 -0000 John Baldwin wrote: > On Tuesday 22 December 2009 8:49:53 pm David Xu wrote: >> This is my first attempt to make process-shared mutex work, this means >> you can mmap(MAP_SHARED) a memory area, and put semaphore there, >> or you can sem_open a named semaphore, and just use it between >> processes, the named semaphore uses file system and mmap(), directory >> /tmp/.semaphore is used as IPC directory, any named semaphore >> locates in the directory. old semaphore implementation still exists >> to make it binary compatible, it uses symbol version. >> >> http://people.freebsd.org/~davidxu/patch/shared_semaphore_1.patch > > I would suggest that you leave named semaphores as they currently exist and > follow this approach instead: > > 1) Named semaphores use ksem_*() still. > 2) sem_init/sem_destroy operate on UTMX-backed semaphores identical to the > ones used in the current libthr code. The semid_t structure now becomes the > full structure that libthr currently allocates with a flag to indicate if it > is a "system" semaphore or otherwise. The pshared flag passed to sem_init() > can be used to set the sharing properties of the UMTX. > 3) All of sem_init/sem_destroy is just in libc. Just move the libthr > implementation bits into libc. > ksem base shared semaphore is slow because whenever you call sem_wait(), it always enters kernel even if count is non-zero, sem_post() also always enters kernel even if there is no waiter. but the new implementation is as simple as just an atomic operation in these cases, I know another competitor OS is doing things in this way. From owner-freebsd-threads@FreeBSD.ORG Thu Dec 24 01:20:30 2009 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 CEF7A106566B; Thu, 24 Dec 2009 01:20:30 +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 BD53A8FC16; Thu, 24 Dec 2009 01:20:30 +0000 (UTC) Received: from apple.my.domain (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nBO1KSg6001520; Thu, 24 Dec 2009 01:20:29 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4B32C1DC.9080308@freebsd.org> Date: Thu, 24 Dec 2009 09:20:28 +0800 From: David Xu User-Agent: Thunderbird 2.0.0.9 (X11/20080612) MIME-Version: 1.0 To: John Baldwin References: <4B317741.8080004@freebsd.org> <200912230936.35998.jhb@freebsd.org> In-Reply-To: <200912230936.35998.jhb@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: threads@freebsd.org, freebsd-threads@freebsd.org Subject: Re: first patch for process-shared semaphore 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, 24 Dec 2009 01:20:30 -0000 John Baldwin wrote: > On Tuesday 22 December 2009 8:49:53 pm David Xu wrote: >> This is my first attempt to make process-shared mutex work, this means >> you can mmap(MAP_SHARED) a memory area, and put semaphore there, >> or you can sem_open a named semaphore, and just use it between >> processes, the named semaphore uses file system and mmap(), directory >> /tmp/.semaphore is used as IPC directory, any named semaphore >> locates in the directory. old semaphore implementation still exists >> to make it binary compatible, it uses symbol version. >> >> http://people.freebsd.org/~davidxu/patch/shared_semaphore_1.patch > > I would suggest that you leave named semaphores as they currently exist and > follow this approach instead: > > 1) Named semaphores use ksem_*() still. > 2) sem_init/sem_destroy operate on UTMX-backed semaphores identical to the > ones used in the current libthr code. The semid_t structure now becomes the > full structure that libthr currently allocates with a flag to indicate if it > is a "system" semaphore or otherwise. The pshared flag passed to sem_init() > can be used to set the sharing properties of the UMTX. > 3) All of sem_init/sem_destroy is just in libc. Just move the libthr > implementation bits into libc. > ksem base shared semaphore is slow because whenever you call sem_wait(), it always enters kernel even if count is non-zero, sem_post() also always enters kernel even if there is no waiter. but the new implementation is as simple as just an atomic operation in these cases, I know another competitor OS is doing things in this way. From owner-freebsd-threads@FreeBSD.ORG Thu Dec 24 01:22:36 2009 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1FA6F1065672 for ; Thu, 24 Dec 2009 01:22:36 +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 0E2E38FC18; Thu, 24 Dec 2009 01:22:36 +0000 (UTC) Received: from apple.my.domain (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nBO1MY3W008163; Thu, 24 Dec 2009 01:22:35 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4B32C25A.8040703@freebsd.org> Date: Thu, 24 Dec 2009 09:22:34 +0800 From: David Xu User-Agent: Thunderbird 2.0.0.9 (X11/20080612) MIME-Version: 1.0 To: Alexander Kabaev References: <4B317741.8080004@freebsd.org> <20091223074707.2a7ca9d6@kan.dnsalias.net> In-Reply-To: <20091223074707.2a7ca9d6@kan.dnsalias.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: threads@freebsd.org Subject: Re: first patch for process-shared semaphore 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, 24 Dec 2009 01:22:36 -0000 Alexander Kabaev wrote: > On Wed, 23 Dec 2009 09:49:53 +0800 > David Xu wrote: > >> This is my first attempt to make process-shared mutex work, this means >> you can mmap(MAP_SHARED) a memory area, and put semaphore there, >> or you can sem_open a named semaphore, and just use it between >> processes, the named semaphore uses file system and mmap(), directory >> /tmp/.semaphore is used as IPC directory, any named semaphore >> locates in the directory. old semaphore implementation still exists >> to make it binary compatible, it uses symbol version. >> >> http://people.freebsd.org/~davidxu/patch/shared_semaphore_1.patch >> >> >> David Xu >> >> _______________________________________________ >> freebsd-threads@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-threads >> To unsubscribe, send any mail to >> "freebsd-threads-unsubscribe@freebsd.org" > > Hi, > > is libthr really required for semaphores? Semaphore API seem > orthogonal to pthreads. None of the man pages on OpenGroup size > indicate where these belong, but they put sem_open & friends into > REALTIME group and Linux has them in librt. > libthr does not require semaphore, it implements semaphore, it is easier than other ways to implement the process-shared. From owner-freebsd-threads@FreeBSD.ORG Thu Dec 24 01:35:47 2009 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7C2AF106568D; Thu, 24 Dec 2009 01:35:47 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from mail-qy0-f176.google.com (mail-qy0-f176.google.com [209.85.221.176]) by mx1.freebsd.org (Postfix) with ESMTP id 16EF18FC16; Thu, 24 Dec 2009 01:35:46 +0000 (UTC) Received: by qyk6 with SMTP id 6so3341729qyk.3 for ; Wed, 23 Dec 2009 17:35:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type; bh=ev7UeFF6G+aywUqGwd+tgMpGAYysyi7CykW+I+/QYL4=; b=mo794FcOhS3Yr/WL9OsszbPLopJbG6A9bH0flMC7ppflcXJh2mTkG0cqsIaxnUH8Bc /BNV1RUz+86Drdih1xVx+SYxbgMXtLYKQWpaU0A6U+GUwLVb/sF4GcONhDwDL6pqyzVO MZjbNq118I+aDzt5OYe3QTxuObVU0cZrYwuAo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=P1IJ92HlFl0ALeHajh4kqvLsLwKk0HMjoMc+ZlcnmzhH6MZsCx/RA0K5H+PJaM+O6Y xOUAZrOWMyK9EVx5vuqMFgHZJWuQ4Glii8Mb9R6WmqDijKjkeW/HqcblTHhTBeO4ST2k VciJI2y7M1/XfZ5YzorAxVhZM6mCR3J8Np37Q= Received: by 10.224.118.81 with SMTP id u17mr5588317qaq.301.1261618546182; Wed, 23 Dec 2009 17:35:46 -0800 (PST) Received: from kan.dnsalias.net (c-24-91-218-112.hsd1.ma.comcast.net [24.91.218.112]) by mx.google.com with ESMTPS id 26sm21960599qwa.10.2009.12.23.17.35.44 (version=SSLv3 cipher=RC4-MD5); Wed, 23 Dec 2009 17:35:44 -0800 (PST) Date: Wed, 23 Dec 2009 20:35:39 -0500 From: Alexander Kabaev To: David Xu Message-ID: <20091223203539.400bbfda@kan.dnsalias.net> In-Reply-To: <4B32C25A.8040703@freebsd.org> References: <4B317741.8080004@freebsd.org> <20091223074707.2a7ca9d6@kan.dnsalias.net> <4B32C25A.8040703@freebsd.org> X-Mailer: Claws Mail 3.7.3 (GTK+ 2.18.5; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/+7Bo6dB7O_nDOeoVAOuLE3L"; protocol="application/pgp-signature" Cc: threads@freebsd.org Subject: Re: first patch for process-shared semaphore 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, 24 Dec 2009 01:35:47 -0000 --Sig_/+7Bo6dB7O_nDOeoVAOuLE3L Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 24 Dec 2009 09:22:34 +0800 David Xu wrote: >=20 > libthr does not require semaphore, it implements semaphore, > it is easier than other ways to implement the process-shared. >=20 Let me rephrase: I do not think semaphores belong in libthr. They should be either in libc or in librt. --=20 Alexander Kabaev --Sig_/+7Bo6dB7O_nDOeoVAOuLE3L Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) iD8DBQFLMsVvQ6z1jMm+XZYRAjYbAKCBSP5xlkf2FtW59aGnANESoejTPQCeJNg6 ys59wGlyx/A4wSDBq783IkM= =rf71 -----END PGP SIGNATURE----- --Sig_/+7Bo6dB7O_nDOeoVAOuLE3L-- From owner-freebsd-threads@FreeBSD.ORG Thu Dec 24 01:58:52 2009 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7C00F1065695 for ; Thu, 24 Dec 2009 01:58:52 +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 50EB98FC1D; Thu, 24 Dec 2009 01:58:52 +0000 (UTC) Received: from apple.my.domain (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nBO1wo4w035592; Thu, 24 Dec 2009 01:58:51 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4B32CADA.4010407@freebsd.org> Date: Thu, 24 Dec 2009 09:58:50 +0800 From: David Xu User-Agent: Thunderbird 2.0.0.9 (X11/20080612) MIME-Version: 1.0 To: Alexander Kabaev References: <4B317741.8080004@freebsd.org> <20091223074707.2a7ca9d6@kan.dnsalias.net> <4B32C25A.8040703@freebsd.org> <20091223203539.400bbfda@kan.dnsalias.net> In-Reply-To: <20091223203539.400bbfda@kan.dnsalias.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: threads@freebsd.org Subject: Re: first patch for process-shared semaphore 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, 24 Dec 2009 01:58:52 -0000 Alexander Kabaev wrote: > On Thu, 24 Dec 2009 09:22:34 +0800 > David Xu wrote: >> libthr does not require semaphore, it implements semaphore, >> it is easier than other ways to implement the process-shared. >> > Let me rephrase: I do not think semaphores belong in libthr. They > should be either in libc or in librt. > > OK, does others really implement semaphore in librt ? unfortunately, the librt already requires libpthread to implement SIGEV_THREAD. From owner-freebsd-threads@FreeBSD.ORG Thu Dec 24 03:12:26 2009 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 76048106566C; Thu, 24 Dec 2009 03:12:26 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.27]) by mx1.freebsd.org (Postfix) with ESMTP id 10A8F8FC13; Thu, 24 Dec 2009 03:12:25 +0000 (UTC) Received: by qw-out-2122.google.com with SMTP id 9so1668018qwb.7 for ; Wed, 23 Dec 2009 19:12:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type; bh=W9hteEqC2YmqAoyRhRlGym1I6364v9OsSs07b/iY29w=; b=nlkVVJ5uLIbPGZmPlVN2BugQjCa375VJkvk8B6H11/8wKOWfF05NQeVznipUwyTUKX X4rtIWz1tiPJV3gQ42jm4gInJkSxsQqj1getzpW31+LSTwYqenGMkGpu5iHpA0scwJQ6 OuuLN/FW7HUmTCx127SwqqDLfU74tythA65dA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=vUQAXuDFQnDXnfbtgjj7hm4Glo9aVUHBvKYAsgvKYjaKiesS9pu///fXr5tyFdQUk0 ETwfD/SU29XfYAmBgTHksortOsk862XneDVlc4VeI8076+CnUq6kYSOFJVKYkzFQ3URc jo1cPE95OF0+v1vy8XrwNgt275a8ucYGBQpKY= Received: by 10.224.56.203 with SMTP id z11mr5627733qag.265.1261624345419; Wed, 23 Dec 2009 19:12:25 -0800 (PST) Received: from kan.dnsalias.net (c-24-91-218-112.hsd1.ma.comcast.net [24.91.218.112]) by mx.google.com with ESMTPS id 5sm22028102qwg.58.2009.12.23.19.12.24 (version=SSLv3 cipher=RC4-MD5); Wed, 23 Dec 2009 19:12:24 -0800 (PST) Date: Wed, 23 Dec 2009 22:12:19 -0500 From: Alexander Kabaev To: David Xu Message-ID: <20091223221219.4416cef6@kan.dnsalias.net> In-Reply-To: <4B32CADA.4010407@freebsd.org> References: <4B317741.8080004@freebsd.org> <20091223074707.2a7ca9d6@kan.dnsalias.net> <4B32C25A.8040703@freebsd.org> <20091223203539.400bbfda@kan.dnsalias.net> <4B32CADA.4010407@freebsd.org> X-Mailer: Claws Mail 3.7.3 (GTK+ 2.18.5; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/Q1pKAvMK=kns27.hzjBik+8"; protocol="application/pgp-signature" Cc: threads@freebsd.org Subject: Re: first patch for process-shared semaphore 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, 24 Dec 2009 03:12:26 -0000 --Sig_/Q1pKAvMK=kns27.hzjBik+8 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 24 Dec 2009 09:58:50 +0800 David Xu wrote: > Alexander Kabaev wrote: > > On Thu, 24 Dec 2009 09:22:34 +0800 > > David Xu wrote: > >> libthr does not require semaphore, it implements semaphore, > >> it is easier than other ways to implement the process-shared. > >> > > Let me rephrase: I do not think semaphores belong in libthr. They > > should be either in libc or in librt. > >=20 > >=20 > OK, does others really implement semaphore in librt ? > unfortunately, the librt already requires libpthread to implement > SIGEV_THREAD. I retract that. It appears that there is no consistency - Solaris put these into libc, Linux into libpthread ans SUSv2 hints that these belong with realtime functions. libthr is fine. --=20 Alexander Kabaev --Sig_/Q1pKAvMK=kns27.hzjBik+8 Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) iD8DBQFLMtwXQ6z1jMm+XZYRAsYhAKCKoVhQA16GT2PSKkoIdMjs53CLmQCffyWV ZwV0bNkdFJ5aCCveMhASsjc= =4hAT -----END PGP SIGNATURE----- --Sig_/Q1pKAvMK=kns27.hzjBik+8-- From owner-freebsd-threads@FreeBSD.ORG Thu Dec 24 13:00:28 2009 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 4BB42106568D; Thu, 24 Dec 2009 13:00:28 +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 1E17F8FC13; Thu, 24 Dec 2009 13:00:28 +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 C5A0B46B06; Thu, 24 Dec 2009 08:00:27 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 792978A01D; Thu, 24 Dec 2009 08:00:26 -0500 (EST) From: John Baldwin To: David Xu Date: Thu, 24 Dec 2009 07:55:11 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20091103; KDE/4.3.1; amd64; ; ) References: <4B317741.8080004@freebsd.org> <200912230936.35998.jhb@freebsd.org> <4B32C1DC.9080308@freebsd.org> In-Reply-To: <4B32C1DC.9080308@freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912240755.11841.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Thu, 24 Dec 2009 08:00:27 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: freebsd-threads@freebsd.org Subject: Re: first patch for process-shared semaphore 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, 24 Dec 2009 13:00:28 -0000 On Wednesday 23 December 2009 8:20:28 pm David Xu wrote: > John Baldwin wrote: > > On Tuesday 22 December 2009 8:49:53 pm David Xu wrote: > >> This is my first attempt to make process-shared mutex work, this means > >> you can mmap(MAP_SHARED) a memory area, and put semaphore there, > >> or you can sem_open a named semaphore, and just use it between > >> processes, the named semaphore uses file system and mmap(), directory > >> /tmp/.semaphore is used as IPC directory, any named semaphore > >> locates in the directory. old semaphore implementation still exists > >> to make it binary compatible, it uses symbol version. > >> > >> http://people.freebsd.org/~davidxu/patch/shared_semaphore_1.patch > > > > I would suggest that you leave named semaphores as they currently exist and > > follow this approach instead: > > > > 1) Named semaphores use ksem_*() still. > > 2) sem_init/sem_destroy operate on UTMX-backed semaphores identical to the > > ones used in the current libthr code. The semid_t structure now becomes the > > full structure that libthr currently allocates with a flag to indicate if it > > is a "system" semaphore or otherwise. The pshared flag passed to sem_init() > > can be used to set the sharing properties of the UMTX. > > 3) All of sem_init/sem_destroy is just in libc. Just move the libthr > > implementation bits into libc. > > > > ksem base shared semaphore is slow because whenever you call > sem_wait(), it always enters kernel even if count is non-zero, > sem_post() also always enters kernel even if there is no waiter. > but the new implementation is as simple as just an atomic operation > in these cases, I know another competitor OS is doing things in > this way. Yes, Solaris uses files in /tmp and Darwin uses special file descriptors similar to what we do. However, you will have to restrict the namespace if you go the /tmp route to be safe I think similar to what Solaris does (no path separators, just simple names like 'foo'). You might also want to use the same naming convention as Solaris if you go the /tmp route (I think they use a path other than .semaphore under /tmp IIRC). Not sure if we want to do anything special to ensure that those particular set of files in /tmp always get purged on reboot to avoid weird bugs with semaphores unexpectedly persisting across reboots. -- John Baldwin From owner-freebsd-threads@FreeBSD.ORG Thu Dec 24 13:00:31 2009 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 B7049106568F; Thu, 24 Dec 2009 13:00:31 +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 882C28FC16; Thu, 24 Dec 2009 13:00:31 +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 3A0B246B06; Thu, 24 Dec 2009 08:00:31 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 98A4F8A01B; Thu, 24 Dec 2009 08:00:30 -0500 (EST) From: John Baldwin To: freebsd-threads@freebsd.org Date: Thu, 24 Dec 2009 07:59:47 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20091103; KDE/4.3.1; amd64; ; ) References: <4B317741.8080004@freebsd.org> <4B32CADA.4010407@freebsd.org> <20091223221219.4416cef6@kan.dnsalias.net> In-Reply-To: <20091223221219.4416cef6@kan.dnsalias.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <200912240759.47703.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Thu, 24 Dec 2009 08:00:30 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: threads@freebsd.org, David Xu Subject: Re: first patch for process-shared semaphore 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, 24 Dec 2009 13:00:31 -0000 On Wednesday 23 December 2009 10:12:19 pm Alexander Kabaev wrote: > On Thu, 24 Dec 2009 09:58:50 +0800 > David Xu wrote: > > > Alexander Kabaev wrote: > > > On Thu, 24 Dec 2009 09:22:34 +0800 > > > David Xu wrote: > > >> libthr does not require semaphore, it implements semaphore, > > >> it is easier than other ways to implement the process-shared. > > >> > > > Let me rephrase: I do not think semaphores belong in libthr. They > > > should be either in libc or in librt. > > > > > > > > OK, does others really implement semaphore in librt ? > > unfortunately, the librt already requires libpthread to implement > > SIGEV_THREAD. > > I retract that. It appears that there is no consistency - Solaris put > these into libc, Linux into libpthread ans SUSv2 hints that these > belong with realtime functions. libthr is fine. I vote for libc. Single-threaded processes can use sem_open() and PSHARED sem_init() as well. Single-threaded processes can even use non-PSHARED sem_init() by using fork() to create new "threads" that share the semaphore. -- John Baldwin From owner-freebsd-threads@FreeBSD.ORG Thu Dec 24 13:00:31 2009 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7049106568F; Thu, 24 Dec 2009 13:00:31 +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 882C28FC16; Thu, 24 Dec 2009 13:00:31 +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 3A0B246B06; Thu, 24 Dec 2009 08:00:31 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 98A4F8A01B; Thu, 24 Dec 2009 08:00:30 -0500 (EST) From: John Baldwin To: freebsd-threads@freebsd.org Date: Thu, 24 Dec 2009 07:59:47 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20091103; KDE/4.3.1; amd64; ; ) References: <4B317741.8080004@freebsd.org> <4B32CADA.4010407@freebsd.org> <20091223221219.4416cef6@kan.dnsalias.net> In-Reply-To: <20091223221219.4416cef6@kan.dnsalias.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <200912240759.47703.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Thu, 24 Dec 2009 08:00:30 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: threads@freebsd.org, David Xu Subject: Re: first patch for process-shared semaphore 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, 24 Dec 2009 13:00:31 -0000 On Wednesday 23 December 2009 10:12:19 pm Alexander Kabaev wrote: > On Thu, 24 Dec 2009 09:58:50 +0800 > David Xu wrote: > > > Alexander Kabaev wrote: > > > On Thu, 24 Dec 2009 09:22:34 +0800 > > > David Xu wrote: > > >> libthr does not require semaphore, it implements semaphore, > > >> it is easier than other ways to implement the process-shared. > > >> > > > Let me rephrase: I do not think semaphores belong in libthr. They > > > should be either in libc or in librt. > > > > > > > > OK, does others really implement semaphore in librt ? > > unfortunately, the librt already requires libpthread to implement > > SIGEV_THREAD. > > I retract that. It appears that there is no consistency - Solaris put > these into libc, Linux into libpthread ans SUSv2 hints that these > belong with realtime functions. libthr is fine. I vote for libc. Single-threaded processes can use sem_open() and PSHARED sem_init() as well. Single-threaded processes can even use non-PSHARED sem_init() by using fork() to create new "threads" that share the semaphore. -- John Baldwin From owner-freebsd-threads@FreeBSD.ORG Thu Dec 24 16:53:42 2009 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 13191106568B for ; Thu, 24 Dec 2009 16:53:42 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-fx0-f227.google.com (mail-fx0-f227.google.com [209.85.220.227]) by mx1.freebsd.org (Postfix) with ESMTP id 9B56E8FC1D for ; Thu, 24 Dec 2009 16:53:41 +0000 (UTC) Received: by fxm27 with SMTP id 27so8446144fxm.3 for ; Thu, 24 Dec 2009 08:53:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=Z7gKUO5h3FcHhRcnh9gsDAjL9AOxsdDty8+uH2bvkIE=; b=Mfz+aJ2yHACGsC699e9+DBDfj/AeNRC8tHzH+uzlT5uPmwJ19UiJtnpvj95Ta/qQkC QqBdXIhtYmc1euZs17jCfNNEn0ULCYO8RUvz7ebgcI96cwTynNB+Ae5wua84bvjt49w1 hP8Z1KdnzZbiDKZ9SLYLjtkorX0YUOhRzVWUY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=ffU4gnetC5xwc3yVb+hJGWxWJ6apAjW716fZhdwNcVcMXtV6SnparCMQy/qE9rwCTL UJvzQ7EKDzVo+Vjt2WSrfSFRieLzgbtON1hNPd4IUpyxo25lIAqj0b2rHvqB+uA3pQ4M 1SE6Dqy6QwznKYP09FDMeRosMye+ghqmlpk9E= MIME-Version: 1.0 Sender: asmrookie@gmail.com Received: by 10.223.4.132 with SMTP id 4mr7348364far.45.1261672102079; Thu, 24 Dec 2009 08:28:22 -0800 (PST) In-Reply-To: <20091223221219.4416cef6@kan.dnsalias.net> References: <4B317741.8080004@freebsd.org> <20091223074707.2a7ca9d6@kan.dnsalias.net> <4B32C25A.8040703@freebsd.org> <20091223203539.400bbfda@kan.dnsalias.net> <4B32CADA.4010407@freebsd.org> <20091223221219.4416cef6@kan.dnsalias.net> Date: Thu, 24 Dec 2009 17:28:22 +0100 X-Google-Sender-Auth: 40908e5533c483c5 Message-ID: <3bbf2fe10912240828x636d9f3ficc9035b0aa584334@mail.gmail.com> From: Attilio Rao To: Alexander Kabaev Content-Type: text/plain; charset=UTF-8 Cc: threads@freebsd.org, David Xu Subject: Re: first patch for process-shared semaphore 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, 24 Dec 2009 16:53:42 -0000 2009/12/24 Alexander Kabaev : > On Thu, 24 Dec 2009 09:58:50 +0800 > David Xu wrote: > >> Alexander Kabaev wrote: >> > On Thu, 24 Dec 2009 09:22:34 +0800 >> > David Xu wrote: >> >> libthr does not require semaphore, it implements semaphore, >> >> it is easier than other ways to implement the process-shared. >> >> >> > Let me rephrase: I do not think semaphores belong in libthr. They >> > should be either in libc or in librt. >> > >> > >> OK, does others really implement semaphore in librt ? >> unfortunately, the librt already requires libpthread to implement >> SIGEV_THREAD. > > I retract that. It appears that there is no consistency - Solaris put > these into libc, Linux into libpthread ans SUSv2 hints that these > belong with realtime functions. libthr is fine. Beside that, though, semaphores should be thread library-agnostic so I would implement them into a different namespace (libc, for the POSIX compatibility, seems the most appropriate choice). Attilio -- Peace can only be achieved by understanding - A. Einstein From owner-freebsd-threads@FreeBSD.ORG Fri Dec 25 01:05:43 2009 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 67E701065670; Fri, 25 Dec 2009 01:05:43 +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 3C6C68FC0A; Fri, 25 Dec 2009 01:05:43 +0000 (UTC) Received: from apple.my.domain (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nBP15eeN047838; Fri, 25 Dec 2009 01:05:41 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4B340FE4.9060108@freebsd.org> Date: Fri, 25 Dec 2009 09:05:40 +0800 From: David Xu User-Agent: Thunderbird 2.0.0.9 (X11/20080612) MIME-Version: 1.0 To: John Baldwin References: <4B317741.8080004@freebsd.org> <4B32CADA.4010407@freebsd.org> <20091223221219.4416cef6@kan.dnsalias.net> <200912240759.47703.jhb@freebsd.org> In-Reply-To: <200912240759.47703.jhb@freebsd.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Cc: threads@freebsd.org, freebsd-threads@freebsd.org Subject: Re: first patch for process-shared semaphore 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, 25 Dec 2009 01:05:43 -0000 John Baldwin wrote: > On Wednesday 23 December 2009 10:12:19 pm Alexander Kabaev wrote: >> On Thu, 24 Dec 2009 09:58:50 +0800 >> David Xu wrote: >> >>> Alexander Kabaev wrote: >>>> On Thu, 24 Dec 2009 09:22:34 +0800 >>>> David Xu wrote: >>>>> libthr does not require semaphore, it implements semaphore, >>>>> it is easier than other ways to implement the process-shared. >>>>> >>>> Let me rephrase: I do not think semaphores belong in libthr. They >>>> should be either in libc or in librt. >>>> >>>> >>> OK, does others really implement semaphore in librt ? >>> unfortunately, the librt already requires libpthread to implement >>> SIGEV_THREAD. >> I retract that. It appears that there is no consistency - Solaris put >> these into libc, Linux into libpthread ans SUSv2 hints that these >> belong with realtime functions. libthr is fine. > > I vote for libc. Single-threaded processes can use sem_open() and PSHARED > sem_init() as well. Single-threaded processes can even use non-PSHARED > sem_init() by using fork() to create new "threads" that share the semaphore. > OK, but will symbol version work in this way ? we already have sem_init() in libthr, if we implement version 1.2 in libc, can linker find newest version? I guess version 1.1 in libthr will be resolved first by linker. for example: cc -o threading_sem_test threading_sem_test.c -lthr won't vesion 1.1 of sem_init in libthr be use firstly ? this is obviously wrong. From owner-freebsd-threads@FreeBSD.ORG Fri Dec 25 01:05:43 2009 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 67E701065670; Fri, 25 Dec 2009 01:05:43 +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 3C6C68FC0A; Fri, 25 Dec 2009 01:05:43 +0000 (UTC) Received: from apple.my.domain (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nBP15eeN047838; Fri, 25 Dec 2009 01:05:41 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4B340FE4.9060108@freebsd.org> Date: Fri, 25 Dec 2009 09:05:40 +0800 From: David Xu User-Agent: Thunderbird 2.0.0.9 (X11/20080612) MIME-Version: 1.0 To: John Baldwin References: <4B317741.8080004@freebsd.org> <4B32CADA.4010407@freebsd.org> <20091223221219.4416cef6@kan.dnsalias.net> <200912240759.47703.jhb@freebsd.org> In-Reply-To: <200912240759.47703.jhb@freebsd.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Cc: threads@freebsd.org, freebsd-threads@freebsd.org Subject: Re: first patch for process-shared semaphore 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, 25 Dec 2009 01:05:43 -0000 John Baldwin wrote: > On Wednesday 23 December 2009 10:12:19 pm Alexander Kabaev wrote: >> On Thu, 24 Dec 2009 09:58:50 +0800 >> David Xu wrote: >> >>> Alexander Kabaev wrote: >>>> On Thu, 24 Dec 2009 09:22:34 +0800 >>>> David Xu wrote: >>>>> libthr does not require semaphore, it implements semaphore, >>>>> it is easier than other ways to implement the process-shared. >>>>> >>>> Let me rephrase: I do not think semaphores belong in libthr. They >>>> should be either in libc or in librt. >>>> >>>> >>> OK, does others really implement semaphore in librt ? >>> unfortunately, the librt already requires libpthread to implement >>> SIGEV_THREAD. >> I retract that. It appears that there is no consistency - Solaris put >> these into libc, Linux into libpthread ans SUSv2 hints that these >> belong with realtime functions. libthr is fine. > > I vote for libc. Single-threaded processes can use sem_open() and PSHARED > sem_init() as well. Single-threaded processes can even use non-PSHARED > sem_init() by using fork() to create new "threads" that share the semaphore. > OK, but will symbol version work in this way ? we already have sem_init() in libthr, if we implement version 1.2 in libc, can linker find newest version? I guess version 1.1 in libthr will be resolved first by linker. for example: cc -o threading_sem_test threading_sem_test.c -lthr won't vesion 1.1 of sem_init in libthr be use firstly ? this is obviously wrong. From owner-freebsd-threads@FreeBSD.ORG Fri Dec 25 01:15:48 2009 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 058851065759; Fri, 25 Dec 2009 01:15:47 +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 2B1428FC18; Fri, 25 Dec 2009 01:15:47 +0000 (UTC) Received: from apple.my.domain (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nBP1FjEY057507; Fri, 25 Dec 2009 01:15:46 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4B341241.9090208@freebsd.org> Date: Fri, 25 Dec 2009 09:15:45 +0800 From: David Xu User-Agent: Thunderbird 2.0.0.9 (X11/20080612) MIME-Version: 1.0 To: John Baldwin References: <4B317741.8080004@freebsd.org> <200912230936.35998.jhb@freebsd.org> <4B32C1DC.9080308@freebsd.org> <200912240755.11841.jhb@freebsd.org> In-Reply-To: <200912240755.11841.jhb@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: first patch for process-shared semaphore 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, 25 Dec 2009 01:15:48 -0000 John Baldwin wrote: > Yes, Solaris uses files in /tmp and Darwin uses special file descriptors > similar to what we do. However, you will have to restrict the namespace if > you go the /tmp route to be safe I think similar to what Solaris does (no path > separators, just simple names like 'foo'). I will only allow names like /XXX, make sure to be compatible with current implementation. > You might also want to use the > same naming convention as Solaris if you go the /tmp route (I think they use a > path other than .semaphore under /tmp IIRC). What is their name convention? The patch just create all semaphore files in directory /tmp/.semaphore and semaphore name is not changed. > Not sure if we want to do > anything special to ensure that those particular set of files in /tmp always > get purged on reboot to avoid weird bugs with semaphores unexpectedly > persisting across reboots. > Yes, this is an issue, I would like to purge it on reboot.