• Davide Libenzi's avatar
    signal/timer/event: KAIO eventfd support example · 9c3060be
    Davide Libenzi authored
    This is an example about how to add eventfd support to the current KAIO code,
    in order to enable KAIO to post readiness events to a pollable fd (hence
    compatible with POSIX select/poll).  The KAIO code simply signals the eventfd
    fd when events are ready, and this triggers a POLLIN in the fd.  This patch
    uses a reserved for future use member of the struct iocb to pass an eventfd
    file descriptor, that KAIO will use to post events every time a request
    completes.  At that point, an aio_getevents() will return the completed result
    to a struct io_event.  I made a quick test program to verify the patch, and it
    runs fine here:
    
    http://www.xmailserver.org/eventfd-aio-test.c
    
    The test program uses poll(2), but it'd, of course, work with select and epoll
    too.
    
    This can allow to schedule both block I/O and other poll-able devices
    requests, and wait for results using select/poll/epoll.  In a typical
    scenario, an application would submit KAIO request using aio_submit(), ...
    9c3060be
aio.h 8.1 KB