信号异步是什么意思?
What is meant by a signal being asynchronous?
来自维基百科的两个定义:
In computer science, asynchronous I/O, or non-blocking I/O is a form
of input/output processing that permits other processing to continue
before the transmission has finished.
Signals are a limited form of inter-process communication used in
Unix, Unix-like, and other POSIX-compliant operating systems. A signal
is an asynchronous notification sent to a process or to a specific
thread within the same process in order to notify it of an event that
occurred.
我不太明白什么意思:
A signal is an asynchronous notification sent to a process
这是否意味着,就像 I/O 一样,向进程发送信号,发送信号的进程不等待接收信号的进程的 return 值,并继续前进?
如果信号是同步的,那么发送进程会等待 return 值吗?
在我看来,您在维基百科文章中强调的陈述过于笼统,无法帮助弄清楚正在发生的事情"under the hood."例如,关于回调的实现,请看一下这个Open Group specification 的一部分:
pointer to a function
Catch signal.
On delivery of the signal, the receiving process is to execute the
signal-catching function at the specified address. After returning
from the signal-catching function, the receiving process shall resume
execution at the point at which it was interrupted.
看起来 "asynchronous" 可以被排除在
之外
A signal is an asynchronous notification sent to a process or to a specific thread within the same process in order to notify it of an event that occurred.
信号接收者不知道发送过程是继续还是等待。它对接收方也不重要(除非在协议中 "agreed" 发送方等待或继续,可能规定接收方对响应时间的限制)。
另一种观点可以是:
异步事件可能意味着在接收方处理第一个事件之前,可以从发送方接收到更多相同或不同的事件。
同步事件可能意味着在接收方处理了该类型的前一个同步事件之前,不会从发送方接收到任何相同类型的事件。 (尽管可以从发送方接收到其他类型的同步或异步事件。)
似乎 [a] 事件的同步性声明只与接收者对发送者的期望有关,但我怀疑维基百科的定义指的是发送者 blocking/continuing 它的处理,这对接收者来说并不重要。
这将如何转化为多个发送方向单个接收方发送相同类型的同步事件?
信号是异步的,因为线程可能会在执行中的任何点接收到信号。这与代码中所有其他事物的同步性形成鲜明对比:一条语句紧接着另一条语句,在函数调用之后您期望一个值,这条指令跟在前面的指令之后,等等……您明白了。信号处理程序可以随时开始执行(通常会中断当前流程执行直到完成)。
问题是该段落没有引用相同的 异步 术语:它指的是可以“在后台”执行的非阻塞调用,允许当前线程在等待接收到响应时执行其他任务(注意这个接收是如何异步的,就像信号一样)。
来自维基百科的两个定义:
In computer science, asynchronous I/O, or non-blocking I/O is a form of input/output processing that permits other processing to continue before the transmission has finished.
Signals are a limited form of inter-process communication used in Unix, Unix-like, and other POSIX-compliant operating systems. A signal is an asynchronous notification sent to a process or to a specific thread within the same process in order to notify it of an event that occurred.
我不太明白什么意思:
A signal is an asynchronous notification sent to a process
这是否意味着,就像 I/O 一样,向进程发送信号,发送信号的进程不等待接收信号的进程的 return 值,并继续前进?
如果信号是同步的,那么发送进程会等待 return 值吗?
在我看来,您在维基百科文章中强调的陈述过于笼统,无法帮助弄清楚正在发生的事情"under the hood."例如,关于回调的实现,请看一下这个Open Group specification 的一部分:
pointer to a function
Catch signal.
On delivery of the signal, the receiving process is to execute the signal-catching function at the specified address. After returning from the signal-catching function, the receiving process shall resume execution at the point at which it was interrupted.
看起来 "asynchronous" 可以被排除在
之外A signal is an asynchronous notification sent to a process or to a specific thread within the same process in order to notify it of an event that occurred.
信号接收者不知道发送过程是继续还是等待。它对接收方也不重要(除非在协议中 "agreed" 发送方等待或继续,可能规定接收方对响应时间的限制)。
另一种观点可以是:
异步事件可能意味着在接收方处理第一个事件之前,可以从发送方接收到更多相同或不同的事件。
同步事件可能意味着在接收方处理了该类型的前一个同步事件之前,不会从发送方接收到任何相同类型的事件。 (尽管可以从发送方接收到其他类型的同步或异步事件。)
似乎 [a] 事件的同步性声明只与接收者对发送者的期望有关,但我怀疑维基百科的定义指的是发送者 blocking/continuing 它的处理,这对接收者来说并不重要。
这将如何转化为多个发送方向单个接收方发送相同类型的同步事件?
信号是异步的,因为线程可能会在执行中的任何点接收到信号。这与代码中所有其他事物的同步性形成鲜明对比:一条语句紧接着另一条语句,在函数调用之后您期望一个值,这条指令跟在前面的指令之后,等等……您明白了。信号处理程序可以随时开始执行(通常会中断当前流程执行直到完成)。
问题是该段落没有引用相同的 异步 术语:它指的是可以“在后台”执行的非阻塞调用,允许当前线程在等待接收到响应时执行其他任务(注意这个接收是如何异步的,就像信号一样)。