From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 22 13:07:41 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 03406106566B for ; Thu, 22 Dec 2011 13:07: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 CE8F38FC19 for ; Thu, 22 Dec 2011 13:07:40 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id 871F046B0D; Thu, 22 Dec 2011 08:07:40 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 0399CB969; Thu, 22 Dec 2011 08:07:40 -0500 (EST) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Thu, 22 Dec 2011 07:57:11 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p8; KDE/4.5.5; amd64; ; ) References: <1324533811.54730.YahooMailClassic@web180006.mail.gq1.yahoo.com> In-Reply-To: <1324533811.54730.YahooMailClassic@web180006.mail.gq1.yahoo.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201112220757.11823.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 22 Dec 2011 08:07:40 -0500 (EST) Cc: Sushanth Rai Subject: Re: Using kevent for signalling user app from kernel 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: Thu, 22 Dec 2011 13:07:41 -0000 On Thursday, December 22, 2011 1:03:31 am Sushanth Rai wrote: > Hi, > > I'm planning to use kqueue/kevent mechanism to notify a user application from the kernel. Basically I set up a file descriptor for read event from the user application by calling kevent(). Now, I would like to wake-up the process from within the kernel. The wake-up will happen due to one of the internal events (not due to data being available to read). I have access to the process structure and vnode corresponding to file descriptor. Is there a mechanism available from the kernel to trigger a wakeup and clear the kernel break notify message ? In the kernel you'd typically use KNOTE() to signal that an event should be signalled. However, that will only post the event if the file is now readable. I think you have a couple of options: 1) You can send a signal to the process which will interrupt the kevent. 2) You can add a new filter type and use it with your file descriptor to signal your special side-band events. The userland app will have to add both an EVFILT_READ event and and event for your custom filter type. You can then use KNOTE when your side-band event happens and your custom filter's f_event hook can signal the event in that case. -- John Baldwin