gpt4 book ai didi

c - 中断对上下文的干扰有多大?如何恢复它?

转载 作者:行者123 更新时间:2023-11-30 15:49:27 25 4
gpt4 key购买 nike

§5.1.2.3.5

5 When the processing of the abstract machine is interrupted byreceipt of a signal, the values of objects that are neither lock-freeatomic objects nor of type volatile sig_atomic_t are not specified,as is the state of the floating-point environment. The value of anyobject modified by the handler that is neither a lock-free atomicobject nor of type volatile sig_atomic_t becomes indeterminate whenthe handler exits, as does the state of the floating-point environmentif it is modified by the handler and not restored to its originalstate.

(强调我的)

我认为这意味着,在硬件/软件中断的情况下,如果中断处理程序执行任何浮点计算(例如在其本地堆栈变量上),则被中断的进程将处于不一致的状态,并且必须重新启动任何浮点计算。正在进行的浮点计算。 是这样吗?这意味着什么?如何“恢复上下文”?

最佳答案

“浮点环境”是指浮点异常和舍入模式的设置,由 fesetround() 等函数修改。

您可以使用fegetenv()保存当前浮点环境,并使用fesetenv()恢复它。如果您安装了执行浮点运算的信号处理程序,那么它应该执行此操作(例如,这确保它不会更改其中断的代码当前引发的浮点异常集)。

关于c - 中断对上下文的干扰有多大?如何恢复它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16272664/

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