I have a device that is a source of data. It is connected to a PC where my program is running. I have two scenarios of how to get the data from that device.
I am wondering, which one is synchronous and which is asynchronous data transmission?
- I start the device and my program executes a thread that periodically polls the device for new data.
- I register a callback function in my program with the device and whenever there is new data available, the device calls my callback function.
-
2Neither are synchronous. See en.wikipedia.org/wiki/…Robert Harvey– Robert Harvey08/04/2015 14:40:28Commented Aug 4, 2015 at 14:40
-
Synchronous vs. Asynchronous is a property of the internal threading of some program. One-way vs. Round-Trip (and push vs. pull) are properties of message transmission. These sets of terms are related but describe different aspects of programming and system construction.Erik Eidt– Erik Eidt08/04/2015 16:39:06Commented Aug 4, 2015 at 16:39
2 Answers 2
I'm not really sure the title question relates to the question in the post. I am assuming that the IO operations seem to be the correct question here.
Synchronous and asynchronous IO operations
This would normally mean that a request to IO would wait for a response before execution continues. Asynchronous operation make a request to IO, typically together with a callback or an identified signal that is then used by the IO handler to callback or signal the original caller of the result.
In your question; 1 would be typical of synchronous operations, and 2 for asynchronous operations.
Side note:
Synchronous and asynchronous data transmission
This relates to the synchronised (or not) communication of the underlying physical link (on the wire if you will). In synchronous schemes, there is typically a clock line that synchronises clients on the wire. In the absence of a clock, clients could attempt to access the line at any point.
Neither is a synchronous operation. In both cases your program will continue running while the data loads, and will later get the data once it finishes loading. That is an asynchronous approach to loading data.
Synchronous data loading would be if the program stops entirely until the data is loaded.