After looking at the differences between kqueue(2) and libevent, I decided it would be best to write a very thin wrapper library to emulate kqueue on non-BSD platforms. I've gotten pretty far with the effort to port kqueue to Linux, and wanted to let everyone know that this is a work-in-progress. The working title of this effort is "libkqueue". If you are curious, you can download the libkqueue source code from here: http://mark.heily.com/src/ Currently, I have implemented the EVFILT_READ, EVFILT_WRITE, and EVFILT_SIGNAL filter types. I plan to implement EVFILT_VNODE using inotify, and EVFILT_TIMER using timerfds. I might have to implement EVFILT_PROC using a helper thread. After the Linux port is complete, I'll consider other Unixes such as OpenSolaris. I'm not a Windows developer, so if anyone wants to help with a Windows port, that would be great. It is my hope that the quality and completeness of libkqueue will soon be sufficient enough to be used with libdispatch. Regards, - Mark
Hi Mark, Thanks for putting this together, it looks really promising! I hope to have the time to look at it in more depth early this week, and am happy to answer any questions you have about how libdispatch uses the kqueue API. Also, please keep us posted on your progress. Kevin On Sep 27, 2009, at 7:40 PM, Mark Heily wrote:
After looking at the differences between kqueue(2) and libevent, I decided it would be best to write a very thin wrapper library to emulate kqueue on non-BSD platforms. I've gotten pretty far with the effort to port kqueue to Linux, and wanted to let everyone know that this is a work-in-progress. The working title of this effort is "libkqueue".
If you are curious, you can download the libkqueue source code from here:
Currently, I have implemented the EVFILT_READ, EVFILT_WRITE, and EVFILT_SIGNAL filter types. I plan to implement EVFILT_VNODE using inotify, and EVFILT_TIMER using timerfds. I might have to implement EVFILT_PROC using a helper thread. After the Linux port is complete, I'll consider other Unixes such as OpenSolaris. I'm not a Windows developer, so if anyone wants to help with a Windows port, that would be great.
It is my hope that the quality and completeness of libkqueue will soon be sufficient enough to be used with libdispatch.
Regards,
- Mark
On 09/28/2009 05:11 AM, Kevin Van Vechten wrote:
I might have to implement EVFILT_PROC using a helper thread.
For NOTE_EXIT only you can use a SIGCHLD signalfd. For anything else you'd need to use ptrace, which is probably not a great idea... However, note that signalfd only works if you can guarantee that all threads have blocked that signal. signalfd competes with sigaction/sigwait rather than being lower priority; if a process signal is given to another thread while you are reading on the signalfd for it, you lose it. "All" means that for example that you must block the signal before you call pthread_create (and that's relatively fine) but also before you call _any_ AIO function, because aio_init creates threads that you don't know about and where the signal won't be blocked. Paolo
Paolo Bonzini wrote:
On 09/28/2009 05:11 AM, Kevin Van Vechten wrote:
I might have to implement EVFILT_PROC using a helper thread.
For NOTE_EXIT only you can use a SIGCHLD signalfd.
For anything else you'd need to use ptrace, which is probably not a great idea...
Agreed. There really isn't a good way to emulate EVFILT_PROC under Linux. I think the best solution would be to write a Linux kernel module to be a "helper" for libkqueue to emulate EVFILT_PROC.
participants (3)
-
Kevin Van Vechten
-
Mark Heily
-
Paolo Bonzini