Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Dec 2011 07:57:11 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-hackers@freebsd.org
Cc:        Sushanth Rai <sushanth_rai@yahoo.com>
Subject:   Re: Using kevent for signalling user app from kernel
Message-ID:  <201112220757.11823.jhb@freebsd.org>
In-Reply-To: <1324533811.54730.YahooMailClassic@web180006.mail.gq1.yahoo.com>
References:  <1324533811.54730.YahooMailClassic@web180006.mail.gq1.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112220757.11823.jhb>