is `write()` asynchronous write?
Another issue that can affect the performance of I/O is whether writes to the file system occur synchronously or asynchronously. Synchronous writes occur in the order in which the disk subsystem receives them, and the writes are not buffered. Thus, the calling routine must wait for the data to reach the disk drive before it can proceed. In an asynchronous write, the data are stored in the cache, and control returns to the caller. Most writes are asynchronous. However, metadata writes, among others, can be synchronous. Operating systems frequently include a flag in the open system call to allow a process to request that writes be performed synchronously. For example, databases use this feature for atomic transactions, to assure that data reach stable storage in the required order.
- In synchronous write, "the writes are not buffered". Are synchronous write and direct I/O the same concept?
- "Operating systems frequently include a flag in the open system call to allow a process to request that writes be performed synchronously." By calling what functions can you achieve synchronous write, and how do you call them? Is it open() with O_DIRECT ?
- Is it correct that write() by default is blocking, and returns when finish writing to the buffer cache, not necessarily to the file? Is write() synchronous write by the definition in the quote?
- aio_write() is also called asynchronous I/O. Is aio_write() asynchronous write or not?