From owner-freebsd-threads@FreeBSD.ORG Sun Mar 21 16:18:41 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 87093106564A for ; Sun, 21 Mar 2010 16:18:41 +0000 (UTC) (envelope-from pldrouin@pldrouin.net) Received: from smtp.cyberfingers.net (smtp.cyberfingers.net [198.177.254.227]) by mx1.freebsd.org (Postfix) with ESMTP id 696E28FC08 for ; Sun, 21 Mar 2010 16:18:41 +0000 (UTC) Received: from [192.168.1.106] (CPE0023695b905f-CM001a666aca96.cpe.net.cable.rogers.com [99.246.67.95]) by smtp.cyberfingers.net (Postfix) with ESMTP id C0676AB6C27 for ; Sun, 21 Mar 2010 11:59:36 -0400 (EDT) Message-ID: <4BA64260.5000009@pldrouin.net> Date: Sun, 21 Mar 2010 11:59:28 -0400 From: Pierre-Luc Drouin User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: freebsd-threads@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Portable Conditional Wait for Inter-Process? 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: Sun, 21 Mar 2010 16:18:41 -0000 Hi, I am looking for a portable solution to put a process into a timed wait (a la pthread_cond_timedwait) such that it can be waken up by another process using something similar to pthread_cond_broadcast (there might be many waiters). I guess shared pthread condition variables are not supported by FreeBSD, right? Is there a portable way to do this? The only solution I can think of right now is to use alarm and sigwait on the waiters side and kill(wpid,SIGCONT) on the other side with a list of pids. Thanks! From owner-freebsd-threads@FreeBSD.ORG Sun Mar 21 17:07:52 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 4A37C106564A for ; Sun, 21 Mar 2010 17:07:52 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 08C488FC08 for ; Sun, 21 Mar 2010 17:07:51 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id o2LH7oHH019778; Sun, 21 Mar 2010 13:07:50 -0400 (EDT) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.2 (mail.netplex.net [204.213.176.10]); Sun, 21 Mar 2010 13:07:50 -0400 (EDT) Date: Sun, 21 Mar 2010 13:07:50 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Pierre-Luc Drouin In-Reply-To: <4BA64260.5000009@pldrouin.net> Message-ID: References: <4BA64260.5000009@pldrouin.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-threads@freebsd.org Subject: Re: Portable Conditional Wait for Inter-Process? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Mar 2010 17:07:52 -0000 On Sun, 21 Mar 2010, Pierre-Luc Drouin wrote: > Hi, > > I am looking for a portable solution to put a process into a timed wait (a la > pthread_cond_timedwait) such that it can be waken up by another process using > something similar to pthread_cond_broadcast (there might be many waiters). I > guess shared pthread condition variables are not supported by FreeBSD, right? > Is there a portable way to do this? The only solution I can think of right > now is to use alarm and sigwait on the waiters side and kill(wpid,SIGCONT) > on the other side with a list of pids. Yeah, shared mutexes and CVs are not yet supported by FreeBSD. You can use sigtimedwait() to conditionally sleep and kill on the other side, but with caveats: o Only one thread per process can be woken with sigwait() and friends o You must ensure that no other threads (other than the waiter) have the "wake" signal unmasked. You might consider using killpg() to send a signal to multiple processes in a process group. FreeBSD current (9.0) recently added support for shared semapores, so you could give those a try. You might be able to use sem_timedwait() instead of pthread_cond_timedwait() depending on your needs, but you are limited to waking only one thread at a time via sem_post(). You could also have a pipe or domain socket between the sender and each waiting processes. I suppose you could use aio_write() on the sender side to write to selected file descriptors with one operation. The waiters would be using poll() or select() with a timeout. -- DE From owner-freebsd-threads@FreeBSD.ORG Sun Mar 21 17:22:27 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 0A704106564A for ; Sun, 21 Mar 2010 17:22:27 +0000 (UTC) (envelope-from pldrouin@pldrouin.net) Received: from smtp.cyberfingers.net (smtp.cyberfingers.net [198.177.254.227]) by mx1.freebsd.org (Postfix) with ESMTP id DC1928FC08 for ; Sun, 21 Mar 2010 17:22:26 +0000 (UTC) Received: from [192.168.1.106] (CPE0023695b905f-CM001a666aca96.cpe.net.cable.rogers.com [99.246.67.95]) by smtp.cyberfingers.net (Postfix) with ESMTP id 38A93AB6C72; Sun, 21 Mar 2010 13:22:26 -0400 (EDT) Message-ID: <4BA655D0.4040002@pldrouin.net> Date: Sun, 21 Mar 2010 13:22:24 -0400 From: Pierre-Luc Drouin User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Daniel Eischen References: <4BA64260.5000009@pldrouin.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: Portable Conditional Wait for Inter-Process? 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: Sun, 21 Mar 2010 17:22:27 -0000 Daniel Eischen wrote: > On Sun, 21 Mar 2010, Pierre-Luc Drouin wrote: > >> Hi, >> >> I am looking for a portable solution to put a process into a timed >> wait (a la pthread_cond_timedwait) such that it can be waken up by >> another process using something similar to pthread_cond_broadcast >> (there might be many waiters). I guess shared pthread condition >> variables are not supported by FreeBSD, right? Is there a portable >> way to do this? The only solution I can think of right now is to use >> alarm and sigwait on the waiters side and kill(wpid,SIGCONT) on the >> other side with a list of pids. > > Yeah, shared mutexes and CVs are not yet supported by FreeBSD. > You can use sigtimedwait() to conditionally sleep and kill > on the other side, but with caveats: > > o Only one thread per process can be woken with > sigwait() and friends > > o You must ensure that no other threads (other than > the waiter) have the "wake" signal unmasked. This should not be a problem in my case.. > > You might consider using killpg() to send a signal to > multiple processes in a process group. yes this is a good idea > > FreeBSD current (9.0) recently added support for shared semapores, > so you could give those a try. You might be able to use > sem_timedwait() instead of pthread_cond_timedwait() depending on > your needs, but you are limited to waking only one thread > at a time via sem_post(). yeah semaphores would not be ideal for my application... I would also prefer to stick with 8.0 for now... > > You could also have a pipe or domain socket between the sender > and each waiting processes. I suppose you could use aio_write() > on the sender side to write to selected file descriptors with > one operation. The waiters would be using poll() or select() > with a timeout. > Thanks for all the good ideas! From owner-freebsd-threads@FreeBSD.ORG Sun Mar 21 22:50:47 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 DE774106564A; Sun, 21 Mar 2010 22:50:47 +0000 (UTC) (envelope-from pldrouin@pldrouin.net) Received: from smtp.cyberfingers.net (smtp.cyberfingers.net [198.177.254.227]) by mx1.freebsd.org (Postfix) with ESMTP id BD19F8FC21; Sun, 21 Mar 2010 22:50:47 +0000 (UTC) Received: from [192.168.1.106] (CPE0023695b905f-CM001a666aca96.cpe.net.cable.rogers.com [99.246.67.95]) by smtp.cyberfingers.net (Postfix) with ESMTP id C03F3AB6C72; Sun, 21 Mar 2010 18:50:46 -0400 (EDT) Message-ID: <4BA6A2C5.3030808@pldrouin.net> Date: Sun, 21 Mar 2010 18:50:45 -0400 From: Pierre-Luc Drouin User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Daniel Eischen References: <4BA64260.5000009@pldrouin.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: Portable Conditional Wait for Inter-Process? 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: Sun, 21 Mar 2010 22:50:48 -0000 Regarding process groups, how can I set two processes to belong to the same process group if they don't have a parent-child relation? Thanks! Daniel Eischen wrote: > On Sun, 21 Mar 2010, Pierre-Luc Drouin wrote: > >> Hi, >> >> I am looking for a portable solution to put a process into a timed >> wait (a la pthread_cond_timedwait) such that it can be waken up by >> another process using something similar to pthread_cond_broadcast >> (there might be many waiters). I guess shared pthread condition >> variables are not supported by FreeBSD, right? Is there a portable >> way to do this? The only solution I can think of right now is to use >> alarm and sigwait on the waiters side and kill(wpid,SIGCONT) on the >> other side with a list of pids. > > Yeah, shared mutexes and CVs are not yet supported by FreeBSD. > You can use sigtimedwait() to conditionally sleep and kill > on the other side, but with caveats: > > o Only one thread per process can be woken with > sigwait() and friends > > o You must ensure that no other threads (other than > the waiter) have the "wake" signal unmasked. > > You might consider using killpg() to send a signal to > multiple processes in a process group. > > FreeBSD current (9.0) recently added support for shared semapores, > so you could give those a try. You might be able to use > sem_timedwait() instead of pthread_cond_timedwait() depending on > your needs, but you are limited to waking only one thread > at a time via sem_post(). > > You could also have a pipe or domain socket between the sender > and each waiting processes. I suppose you could use aio_write() > on the sender side to write to selected file descriptors with > one operation. The waiters would be using poll() or select() > with a timeout. > From owner-freebsd-threads@FreeBSD.ORG Mon Mar 22 11:07:14 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 E9C161065675 for ; Mon, 22 Mar 2010 11:07:13 +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 D8E7C8FC1B for ; Mon, 22 Mar 2010 11:07:13 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o2MB7DDu015181 for ; Mon, 22 Mar 2010 11:07:13 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o2MB7D0n015179 for freebsd-threads@FreeBSD.org; Mon, 22 Mar 2010 11:07:13 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 22 Mar 2010 11:07:13 GMT Message-Id: <201003221107.o2MB7D0n015179@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, 22 Mar 2010 11:07:14 -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/143115 threads [patch] pthread_join() can return EOPNOTSUPP 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/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 Mar 22 15:54:56 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 AEA7E106564A for ; Mon, 22 Mar 2010 15:54:56 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 50DF68FC26 for ; Mon, 22 Mar 2010 15:54:56 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id o2MFssP1002732; Mon, 22 Mar 2010 11:54:54 -0400 (EDT) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.2 (mail.netplex.net [204.213.176.10]); Mon, 22 Mar 2010 11:54:55 -0400 (EDT) Date: Mon, 22 Mar 2010 11:54:54 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Pierre-Luc Drouin In-Reply-To: <4BA6A2C5.3030808@pldrouin.net> Message-ID: References: <4BA64260.5000009@pldrouin.net> <4BA6A2C5.3030808@pldrouin.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-threads@freebsd.org Subject: Re: Portable Conditional Wait for Inter-Process? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Mar 2010 15:54:56 -0000 On Sun, 21 Mar 2010, Pierre-Luc Drouin wrote: > Regarding process groups, how can I set two processes to belong to the same > process group if they don't have a parent-child relation? > > Thanks! Well, from skimming the man pages, I don't think you can do that. You can't somehow launch your clients and server from the same parent? -- DE From owner-freebsd-threads@FreeBSD.ORG Wed Mar 24 15:56:37 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 26E591065672; Wed, 24 Mar 2010 15:56:37 +0000 (UTC) (envelope-from pldrouin@pldrouin.net) Received: from smtp.cyberfingers.net (smtp.cyberfingers.net [198.177.254.227]) by mx1.freebsd.org (Postfix) with ESMTP id 0390C8FC0A; Wed, 24 Mar 2010 15:56:36 +0000 (UTC) Received: from [134.117.23.34] (pldrouinlap2-pc.physics.carleton.ca [134.117.23.34]) by smtp.cyberfingers.net (Postfix) with ESMTP id 065E7AB6C26; Wed, 24 Mar 2010 11:56:35 -0400 (EDT) Message-ID: <4BAA3632.7030309@pldrouin.net> Date: Wed, 24 Mar 2010 11:56:34 -0400 From: Pierre-Luc Drouin User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Daniel Eischen References: <4BA64260.5000009@pldrouin.net> <4BA6A2C5.3030808@pldrouin.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: Portable Conditional Wait for Inter-Process? 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, 24 Mar 2010 15:56:37 -0000 Hi, finally what I did is to create an array in a shared memory segment (I was already using shared memory for these processes) where I write the PIDs of the waiters such that the other process can SIGALRM them when it is ready. The waiters wait for this signal with sigtimedwait and the other process SIGALRM them as well if a signal is sent to it. I use a lock-free algorithm with atomic primitives to save and load the PIDs to the shared segment. It seems to be working quite well. Thanks Daniel Eischen wrote: > On Sun, 21 Mar 2010, Pierre-Luc Drouin wrote: > >> Regarding process groups, how can I set two processes to belong to >> the same process group if they don't have a parent-child relation? >> >> Thanks! > > Well, from skimming the man pages, I don't think you can > do that. You can't somehow launch your clients and server from > the same parent? >