I/O operation combinations¶
I/O operation combinations represent the theoretical cross-section of two behavioral dimensions in computer science: the state of the thread during data preparation (Blocking vs. Non-blocking) and the mechanism for handling I/O completion (Synchronous vs. Asynchronous).^[bio-nio-aio.md]
The Two Dimensions¶
To understand these combinations, it is necessary to distinguish between two separate axes of I/O behavior:
- Blocking vs. Non-blocking: This dimension focuses on the state of the calling thread when data is not yet ready.^[bio-nio-aio.md]
- Blocking: The thread is suspended and waits in place until the result arrives.^[bio-nio-aio.md]
- Non-blocking: The operation returns immediately, allowing the thread to perform other tasks or poll later for the result.^[bio-nio-aio.md]
- Synchronous vs. Asynchronous: This dimension focuses on the communication mechanism for the I/O result between the application and the Operating System.^[bio-nio-aio.md]
- Synchronous: The caller actively initiates the I/O and waits for (or polls for) the process to complete.^[bio-nio-aio.md]
- Asynchronous: The caller does not actively wait for the result; instead, the Operating System handles the I/O and notifies the caller via mechanisms like callbacks or state notifications upon completion.^[bio-nio-aio.md]
Common Combinations¶
While it is possible to theoretically derive four combinations from these dimensions, real-world implementations typically center on the following three^[bio-nio-aio.md]:
- Synchronous Blocking (BIO): The most traditional model where the thread initiates an I/O operation and is suspended until the data is fully prepared and copied.^[bio-nio-aio.md]
- Synchronous Non-blocking (NIO): The thread initiates an I/O operation. If the data is not ready, the call returns immediately, usually requiring the application to poll the status repeatedly.^[bio-nio-aio.md]
- Asynchronous Non-blocking (AIO): The thread initiates an I/O operation and continues processing other work. The Operating System handles the entire I/O process and signals the application (e.g., via a callback) once the data is ready, without the application needing to poll or wait.^[bio-nio-aio.md]
Related Concepts¶
- Java I/O
- Operating System I/O Models
- [[Multiplexing]] (e.g., select/epoll)
Sources¶
- bio-nio-aio.md