From owner-freebsd-hackers@FreeBSD.ORG Mon Sep 19 12:41:19 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA5E8106564A for ; Mon, 19 Sep 2011 12:41:19 +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 BF5EE8FC14 for ; Mon, 19 Sep 2011 12:41:19 +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 7414446B46; Mon, 19 Sep 2011 08:41:19 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 13A868A02F; Mon, 19 Sep 2011 08:41:19 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Mon, 19 Sep 2011 08:25:54 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110617; KDE/4.5.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201109190825.54074.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Mon, 19 Sep 2011 08:41:19 -0400 (EDT) Cc: Jilles Tjoelker , Richard Yao Subject: Re: Mixing Asynchronous Network I/O and POSIX Threads X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2011 12:41:20 -0000 On Sunday, September 18, 2011 5:45:26 pm Richard Yao wrote: > Dear Jilles, > > I am using sigwaitinfo() with all interrupts masked to avoid the > possibility of race conditions in signal handlers, but I have not used > any realtime signals. Linux 2.6.35 found a way to invoke the SIGIO > handler despite it being masked, but that issue would not occur under > production conditions and that is a bug for a different mailing list. > > Being unable to F_SETOWN individual threads would cause problems > because it causes network traffic to become serialized. My code must > run on Linux, but if I were to write FreeBSD-specific code so it would > also work on FreeBSD, would using kqueue enable me to specify which > threads handle events on specific file descriptors? Yes in that you could give each thread its own kqueue fd and register other fd's on the desired thread's kqueue. However, Adrian's point about using libevent is probably worth investigating to see if it will let you achieve that in a portable way. -- John Baldwin