gpt4 book ai didi

multithreading - 信号处理程序运行时的线程状态

转载 作者:行者123 更新时间:2023-12-04 04:31:14 24 4
gpt4 key购买 nike

假设一个多线程应用程序,其中定义了一个信号处理程序。

现在,如果将信号传递给 PROCESS,并调用信号处理程序——我怀疑在信号处理程序运行期间其他线程会发生什么。它们是继续运行,就好像什么都没发生过一样,还是它们在那段时间被暂停......或......?

另外,如果有人可以告诉我为什么要证明答案的合理性?

最佳答案

specification非常清楚信号和线程如何交互:

Signals generated for the process shall be delivered to exactly one of those threads within the process which is in a call to a sigwait() function selecting that signal or has not blocked delivery of the signal.

由于信号只传递给一个线程,其他线程不受影响(并继续运行)。

关于multithreading - 信号处理程序运行时的线程状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4168214/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com