gpt4 book ai didi

haskell - 在GHC RTS的调度程序中,为什么要将功能标记为免费?

转载 作者:行者123 更新时间:2023-12-02 06:09:36 24 4
gpt4 key购买 nike

当我读完the GHC Wiki commentary on the scheduler时我对这一部分感到困惑:

One reason behind marking a Capability as free when it is handed over is to support fast callouts. When making a safe foreign call we have to release the Capability, and therefore hand it over to another worker thread. If the foreign call is short, we don't want to incur the cost of a context switch on returning, but since we marked the Capability as free there's a good chance the returning Task will be able to re-acquire it immediately and continue. The worker that we woke up will find that the Capability is owned, and go back to sleep again (this may incur a double context switch if there are no free CPUs on which to run the worker, however).

我的问题:
对于粗体句子,无论是否将功能标记为免费,确实会导致“双上下文切换”。此外,如果发生的话,这两个“转换”是什么——从 who1 到 who2,然后 who2 到 who3?

最佳答案

关于haskell - 在GHC RTS的调度程序中,为什么要将功能标记为免费?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6046289/

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