0

My textbook usually explains concepts in terms of unix, linux, and windows. However, when it comes to asynchronous and synchronous I/O, it only explains it in the context of windows OS. Because of this, I am wondering if asynchronous and synchronous I/O is OS independent? Are both types of I/O available to all of unix, linux, and windows? Or is it only windows OS that has these abilities.

Thank you.

The Pointer
  • 2,226
  • 7
  • 22
  • 50
  • 2
    They all have it. – kaylum Nov 12 '16 at 05:50
  • The Windows API draws a sharp distinction between asynchronous and synchronous I/O. As far as I know, the Linux API doesn't. You can still achieve much the same thing either way, but you do it differently. – Harry Johnston Nov 12 '16 at 07:55
  • ... my understanding is that Linux doesn't have asynchronous I/O *in the sense that Windows uses the phrase*, i.e., where the user-provided buffer is read from or written to asynchronously. Instead, you issue synchronous calls, but with a guarantee that they won't block. Look up select() for more details. – Harry Johnston Nov 12 '16 at 08:00
  • @user3344003: it's on-topic, but while I didn't close-vote myself I don't think the close votes were incorrect. Compare my interpretation (from the programmer's or API's perspective) with the interpretation in the accepted answer (the hardware perspective, though it also talks about IPC, yet a third interpretation!) and I think it is fair to say that the question isn't sufficiently clear. – Harry Johnston Nov 12 '16 at 21:10
  • POSIX specifies [`lio_listio`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/lio_listio.html) along with [`aio_read`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_read.html), and [`aio_write`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_write.html). The entire set of asynchronous IO calls can be found in the [`aio.h`](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/aio.h.html) header file. – Andrew Henle Nov 13 '16 at 13:31

1 Answers1

1

This is a very broad question, and the answer depends on the context.

For I/O between the CPU and other peripherals, it depends on the hardware I/O interface. Most devices in your system use an synchronous interface, such as the PCI-express bus. Other devices (typically slower performing ones) can use an asynchronous interface to communicate, such as the serial port.

If your question is about inter-process communications within an operating system, the OS typically provides both synchronous or asynchronous methods. This is because certain applications specifically requires synchronous communications, while others requires specifically needs asynchronous communications. You can think of the following question instead: is it crucial for your program to wait for a message to be sent or received before doing anything else, or can you ignore them for now and check up on them later?

Synchronous communications require the sender to wait and do nothing until the message has been successfully delivered by the recipient. The same applies for receiving a message: the receiving process will wait and do nothing until the intended message has been received.

In asynchronous communications, the sender will send out a message, and then proceed with other tasks without waiting. The receiver also do not need to block-wait until a message arrives. It will periodically check to see if any messages are available.

BiN4RY
  • 346
  • 2
  • 5
  • We can check-up on a program when it signals it is finished, rather than automatically checking frequently, right? We can wait for interrupts, as you explained for interrupt-driven I/O and DMA in my previous question http://stackoverflow.com/questions/40541880/what-is-the-difference-between-programmed-polled-i-o-interrupt-driven-i-o-an. – The Pointer Nov 12 '16 at 06:25
  • 1
    Principles of the DMA discussion we had can apply here, but not 100%. – BiN4RY Nov 12 '16 at 06:34
  • 1
    Assuming we're still talking about communication between CPU and peripherals, synchronous I/O means the CPU and a device both know when data are expected, hence "synchronous". This usually involves a handshake protocol, and a common clock keeping the transfer process in sync. In asynchronous I/O, the CPU and device does NOT know when the other will send a message. In this case, both polling and interrupts can be used to handle the unexpected messages. – BiN4RY Nov 12 '16 at 06:39
  • Windows uses the phrase "asynchronous I/O" with a very specific meaning, based on whether the data transfer to or from the buffer provided by the programmer is synchronous or asynchronous. It is likely that this is what the OPs textbook is discussing, nothing to do with the way the I/O is done at the hardware level. – Harry Johnston Nov 12 '16 at 08:02
  • 1
    Yeah true, but the OP also referenced another hardware based question, so I wasn't too sure. If you are indeed referring to IO on the process level, please refer to the second part of my answer. – BiN4RY Nov 12 '16 at 08:18
  • Sadly, IMHO, this answer do not address the question. There are fundamental structural differences between Unix and Windows (and VMS, and RSX) in how they handle I/O. There is not enough room in this little box to go into the differences. – user3344003 Nov 13 '16 at 12:58
  • You are correct, but it sounds like OP just wants to know some very basic understanding about sync/async I/O in general. – BiN4RY Nov 13 '16 at 23:28