linuxasynchronousepollevent-drivenaio

What's the difference between event-driven and asynchronous? Between epoll and AIO?


Event-driven and asynchronous are often used as synonyms. Are there any differences between the two?

Also, what is the difference between epoll and aio? How do they fit together?

Lastly, I've read many times that AIO in Linux is horribly broken. How exactly is it broken?

Thanks.


Solution

  • Events is one of the paradigms to achieve asynchronous execution. But not all asynchronous systems use events. That is about semantic meaning of these two - one is super-entity of another.

    epoll and aio use different metaphors:

    epoll is a blocking operation (epoll_wait()) - you block the thread until some event happens and then you dispatch the event to different procedures/functions/branches in your code.

    In AIO, you pass the address of your callback function (completion routine) to the system and the system calls your function when something happens.

    Problem with AIO is that your callback function code runs on the system thread and so on top of the system stack. A few problems with that as you can imagine.