site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Hello! -- Terry _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... On Jul 31, 2007, at 12:44 AM, Jernej Azarija wrote: I'm implementing a char device that'll be used for communication with userland. The data being transfered is quite asynchronous in it's nature, so I should develop an efficient way of polling. A trivial method to overcome manual polling would be to simply block the calling process until data is available, but I'm interested in the actually poll support implementation. I couldn't find the proper polling support implementation browsing the code of some fd-related stuff in the Darwin code (sys_pipe.c..) so I'm wondering if someone could point me out on how to enable poll in my code so that a daemon reading from my char device could simply use poll()/select(). The internal implementation details for pol()l on Tiger are that it uses an internal kqueue to perform the poll. The implementation details are in bsd/kern/sys_generic.c in the xnu sources (look for "poll" at the start of a line). Internally to kqueue(), there's basically notification sites for various events, indicated by KNOTE(). The KNOTE() macro is not KPI, so these call sites aren't usable in your code (that's because we may need to change internal implementation details for it in software updates to address issues). So you are more likely to get better performance by using kqueue/ kevent directly, rather than using poll. If you need portability, you should probably use select(). In theory, you could depend on BSDKernel and use knote()/knote_attach()/ knote_detach() directly to generate eventts, but in practice you will probably not be happy with this. Basically, select() muxes through to the d_select routine in the cdevsw entry for your character device, which is what everyone eventually calls to see if there's any events to wake up from. This email sent to site_archiver@lists.apple.com