Understanding OS-Backed Event Queues, System Calls, and Cross-Platform Abstractions 44 abstractions might seem a bit unintuitive if you only have a high-level overview of how, for example, IOCP works on Windows. The reason for this is that these abstractions need to provide one API that covers the fact that different operating systems handle the same task differently. This process often involves identifying a common denominator between the platforms and building a new abstraction on top of that. Instead of using a rather complex and lengthy example to explain FFI, syscalls, and cross-platform abstractions, we'll ease into the topic using a simple example. When we encounter these concepts later on, we'll already know these subjects well enough, so we're well prepared for the more interesting examples in the following chapters. In this chapter, we'll go through the following main topics: Why use an OS-backed event queue? Readiness-based event queues Completion-based event queues epoll kqueue IOCP Syscalls, FFI, and cross-platform abstractions Note There are popular, although lesser-used, alternatives you should know about even though we don't cover them here: wepoll : This uses specific APIs on Windows and wraps IOCP so it closely resembles how epoll works on Linux in contrast to regular IOCP. This makes it easier to create an abstraction layer with the same API on top of the two different technologies. It's used by both libuv and mio. io_uring : This is a relatively new API on Linux with many similarities to IOCP on Windows. I'm pretty confident that after you've gone through the next two chapters, you will have an easy time reading up on these if you want to learn more about them. Technical requirements This chapter doesn't require you to set up anything new, but since we're writing some low-level code for three different platforms, you need access to these platforms if you want to run all the examples. The best way to follow along is to open the accompanying repository on your computer and navigate to the ch03 folder.