| This argument is basically hand waving, and it's factually wrong. Yes, switching from user to kernel mode and back is expensive. But let's count the syscalls. Model 1: Threads.
1 blocking read(), 1 blocking write().
Plus cost for the OS scheduler. Model 2:
1 "I want to read", 1 "can I read now?", 1 actual read, 1 "I want to write now", 1 "can I write now?", 1 actual write.
Multiply as necessary if the read or write are only partial.
Add IPC cost as necessary if you have more than one thread handling async events. Measuring by the syscall overhead, blocking I/O is much more efficient. There are other costs to it, though, so it usually consumes more resources per handled socket and turns out to be more expensive than async I/O. But it's not the syscall cost causing it. |