From owner-freebsd-hackers@FreeBSD.ORG Fri Jul 18 22:01:50 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3BFAF37B401 for ; Fri, 18 Jul 2003 22:01:50 -0700 (PDT) Received: from heron.mail.pas.earthlink.net (heron.mail.pas.earthlink.net [207.217.120.189]) by mx1.FreeBSD.org (Postfix) with ESMTP id ABBCD43FB1 for ; Fri, 18 Jul 2003 22:01:49 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from user-38lc0tp.dialup.mindspring.com ([209.86.3.185] helo=mindspring.com) by heron.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 19djqt-00067w-00; Fri, 18 Jul 2003 22:01:47 -0700 Message-ID: <3F18D07F.BEE28FF9@mindspring.com> Date: Fri, 18 Jul 2003 22:00:47 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Marc Ramirez References: <20030718150047.O61759@www.bluecirclesoft.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a40c04773c5ecc3d2d95721e922111a3032601a10902912494350badd9bab72f9c350badd9bab72f9c cc: freebsd-hackers@freebsd.org Subject: Re: Communications kernel -> userland X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jul 2003 05:01:50 -0000 Marc Ramirez wrote: > I asked this in -questions, but got no response; sorry for the repost. > > I have a device driver that needs to make requests for data from a > userland daemon. What's the preferred method for doing this in 4.8R and > 5.1R? I'm assuming the answer is Unix-domain sockets... It depends on the application. In most cases these are set up as request/response protocols. In that case, the best method is to ise an ioctl() or fcntl() (which you use depends on what in the kernel is talking to userland), and then "returning" to user space with the request. The userland then makes another call back down with the response, and the next wait-for-request. This saves you fully 50% of the protection domain crossing system calls from an ordinary callback, and it saves you 300% of the protection domain crossings of what you would need for a pipe/FIFO/unix-domain-socket. E.g.: user kernel ---- ------ REQ1 make_req() sleep_waiting_for_available() ioctl(fd, MY_GETREQ, &req) sleep_waiting_for_req() copyout() sleep_waiting_for_rsp() ioctl(fd, MY_RSPREQ, &req) sleep_waiting_for_req() copyin() ... REQ2 make_req() copyout() sleep_waiting_for_rsp() ioctl(fd, MY_RSPREQ, &req) sleep_waiting_for_req() copyin() ... ... -- Terry