h*****n 发帖数: 209 | 1 【 以下文字转载自 Programming 讨论区 】
发信人: hanuman (神猴), 信区: Programming
标 题: 谁能说说同步/异步IO和阻塞/非阻塞IO的区别?
发信站: BBS 未名空间站 (Mon Jan 24 23:50:56 2011, 美东)
感觉同步I/O就是阻塞I/O,异步I/O就是非阻塞I/O啊,
但是好像这两组概念又不太一样。希望版上的大牛发表高见。 |
s*****y 发帖数: 897 | 2 synchronous means that the OS will work on your IO request once they get you
r request.
asynchronous means the OS will delay to work on your IO request. Maybe it is
because OS is busy working on some other stuff or the IO is not aviable.
Blocking IO means you call the IO function to get the data. The function you
called will not return until the data is avaiable.
Non-Blocking IO means you call the IO function and the IO function returns r
ight away. The IO fucntion will just post a message to the work queue and th
e other process will fetch the message from this queue and then begin to get
the data from the IO. Once the data is ready, they will notify you the data
is ready.
【在 h*****n 的大作中提到】 : 【 以下文字转载自 Programming 讨论区 】 : 发信人: hanuman (神猴), 信区: Programming : 标 题: 谁能说说同步/异步IO和阻塞/非阻塞IO的区别? : 发信站: BBS 未名空间站 (Mon Jan 24 23:50:56 2011, 美东) : 感觉同步I/O就是阻塞I/O,异步I/O就是非阻塞I/O啊, : 但是好像这两组概念又不太一样。希望版上的大牛发表高见。
|
h*****n 发帖数: 209 | 3 Thanks a lot.
Questions from your definition:
1) What if there is no data available for Synchronous IO? In such case
Synchronous IO needs to wait, and it behaves the same as Blocking IO, right?
2) Asynchronous IO is one kind of Non-Blocking IO, right?
you
is
you
r
th
get
data
【在 s*****y 的大作中提到】 : synchronous means that the OS will work on your IO request once they get you : r request. : asynchronous means the OS will delay to work on your IO request. Maybe it is : because OS is busy working on some other stuff or the IO is not aviable. : Blocking IO means you call the IO function to get the data. The function you : called will not return until the data is avaiable. : Non-Blocking IO means you call the IO function and the IO function returns r : ight away. The IO fucntion will just post a message to the work queue and th : e other process will fetch the message from this queue and then begin to get : the data from the IO. Once the data is ready, they will notify you the data
|
h*****n 发帖数: 209 | 4
you
is
you
r
th
get
What does "the other process" mean? Is it a system process?
data
【在 s*****y 的大作中提到】 : synchronous means that the OS will work on your IO request once they get you : r request. : asynchronous means the OS will delay to work on your IO request. Maybe it is : because OS is busy working on some other stuff or the IO is not aviable. : Blocking IO means you call the IO function to get the data. The function you : called will not return until the data is avaiable. : Non-Blocking IO means you call the IO function and the IO function returns r : ight away. The IO fucntion will just post a message to the work queue and th : e other process will fetch the message from this queue and then begin to get : the data from the IO. Once the data is ready, they will notify you the data
|
s*****y 发帖数: 897 | 5 synchronoous and asychronous means whehter the IO prcoess your request once
they get your request.
It depends on how you write your code. You could do synchronous + Blocking o
r synchronous + nonblocking.
right?
【在 h*****n 的大作中提到】 : Thanks a lot. : Questions from your definition: : 1) What if there is no data available for Synchronous IO? In such case : Synchronous IO needs to wait, and it behaves the same as Blocking IO, right? : 2) Asynchronous IO is one kind of Non-Blocking IO, right? : : you : is : you : r
|
s*****y 发帖数: 897 | 6 Your process or your applicaion process may send a message through a message
queue to another IO process who will process your data request.
【在 h*****n 的大作中提到】 : : you : is : you : r : th : get : What does "the other process" mean? Is it a system process? : data
|
h*****n 发帖数: 209 | 7 Thanks.
But we can only do asynchronous + nonblocking, and there is no asynchronous
+ blocking, right?
once
o
【在 s*****y 的大作中提到】 : synchronoous and asychronous means whehter the IO prcoess your request once : they get your request. : It depends on how you write your code. You could do synchronous + Blocking o : r synchronous + nonblocking. : : right?
|
k****n 发帖数: 1334 | 8 4种都有,看这个,解释得很清楚
http://www.ibm.com/developerworks/linux/library/l-async/?S_TACT
asynchronous
【在 h*****n 的大作中提到】 : Thanks. : But we can only do asynchronous + nonblocking, and there is no asynchronous : + blocking, right? : : once : o
|
z*****n 发帖数: 7639 | 9 Synchronous IO, according to its name, the data
is coming in synchronously. Your program/task
should also run synchronously (e.g, by a timer
interrupt) in order to get the data in the same pace.
Asynchrounous IO means data coming in asynchronously.
Your program should be either designed in a fashion
that either incoming data triggers the IO task (i.e.,
interrupt) or the program periodically polls the
IO port for data.
Blocking/Nonblocking IO means how your program deals
with the IO operation. For example, if the polling
function stays (by running a loop) until a piece
of data is obtained, then it is a blocking IO function.
right?
【在 h*****n 的大作中提到】 : Thanks a lot. : Questions from your definition: : 1) What if there is no data available for Synchronous IO? In such case : Synchronous IO needs to wait, and it behaves the same as Blocking IO, right? : 2) Asynchronous IO is one kind of Non-Blocking IO, right? : : you : is : you : r
|
h*****n 发帖数: 209 | 10 I am confused.
I think you are talking about Synchronous Communication and Asynchronous
Communication, not the Synchronous IO and Asynchronous IO.
But actually I am also not sure about the difference between these two kinds
of terms.
【在 z*****n 的大作中提到】 : Synchronous IO, according to its name, the data : is coming in synchronously. Your program/task : should also run synchronously (e.g, by a timer : interrupt) in order to get the data in the same pace. : Asynchrounous IO means data coming in asynchronously. : Your program should be either designed in a fashion : that either incoming data triggers the IO task (i.e., : interrupt) or the program periodically polls the : IO port for data. : Blocking/Nonblocking IO means how your program deals
|
z*****n 发帖数: 7639 | 11 An IO port has no difference from a communication
terminal. What do you think?
kinds
【在 h*****n 的大作中提到】 : I am confused. : I think you are talking about Synchronous Communication and Asynchronous : Communication, not the Synchronous IO and Asynchronous IO. : But actually I am also not sure about the difference between these two kinds : of terms.
|
h*****n 发帖数: 209 | 12 Thanks.
I just want to confirm that 1) Synchronous/Asyschronous IO and 2)
Synchronous/Asyschronous Communication have the same meaning.
【在 z*****n 的大作中提到】 : An IO port has no difference from a communication : terminal. What do you think? : : kinds
|