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.
Asynchronous is basically multitasking. It can spawn off multiple threads or processes to execute a certain function. It's totally different from event driven in the sense that each thread is independent and hardly interact with the main thread in an easy responsive manner.
Event-driven architecture is often referred to as “asynchronous” communication. This means that the sender and recipient don't have to wait for each other to move onto their next task. Systems are not dependent on that one message.
An excellent synchronous example is music. Each participating instrument needs to be in rhythm with the others or else the music won't sound right. For asynchronous, a good example would be traffic. Vehicles move at different rates of speed and it is common for one to move past another.
In general, asynchronous -- pronounced ay-SIHN-kro-nuhs, from Greek asyn-, meaning "not with," and chronos, meaning "time" -- is an adjective describing objects or events that are not coordinated in time.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With