From owner-freebsd-hackers@FreeBSD.ORG Tue May 25 15:18:41 2010 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 9ADCF106567D for ; Tue, 25 May 2010 15:18:41 +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 6C16F8FC13 for ; Tue, 25 May 2010 15:18:41 +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 0A0D446B92; Tue, 25 May 2010 11:18:41 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 810008A01F; Tue, 25 May 2010 11:18:39 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Tue, 25 May 2010 08:55:57 -0400 User-Agent: KMail/1.12.1 (FreeBSD/7.3-CBSD-20100217; KDE/4.3.1; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201005250855.57770.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Tue, 25 May 2010 11:18:39 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.4 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: Dmitry Krivenok Subject: Re: select/poll for sockets in kernel space 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: Tue, 25 May 2010 15:18:41 -0000 On Tuesday 25 May 2010 5:02:35 am Dmitry Krivenok wrote: > Hello Hackers! > > I'm developing a module for FreeBSD-8 and encountered the problem with > polling sockets. > I know that FreeBSD-8 kernel provides 3 interfaces for polling > (kern/sys_generic.c): > 1) kern_select > 2) poll > 3) selsocket > > I cannot use first two interfaces because I have an array of sockets > (struct socket) created using socreate, i.e. I don't have file > descriptors. > I also cannot use selsocket because it doesn't tell me which events > fired and takes only one socket (but I have an array of sockets). > > The problem is that the module I'm developing should work on > unmodified FreeBSD-8 kernel. > So I cannot just add new functionality suitable for my task in > kern/sys_generic.c. > I also cannot implement such functionality in the module itself > because select/poll implementation is hidden and only limited number > of interfaces is available to the rest > of the kernel (which is generally good, but not in my case :)). > > Is it possible to solve my problem using existing kernel functionality? > Any suggestions are welcome! > > Thanks in advance! > > P.S. > I know about kqueue, but I have to use select/poll is this task. Why do you have to use select/poll? If these are dedicated sockets that you create internally, then the right thing to do is probably to install your own upcalls that get called when data for a socket arrives. This is what the in- kernel NFS client does to handle incoming data. -- John Baldwin