简体   繁体   中英

In the scheduler of the GHC RTS, why should it mark a capability as free?

When I read through the GHC Wiki commentary on the scheduler I was confused about this section:

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

My question:
For the bold sentence, what indeed will lead to the "Double context switch", with or without marking a capability as free. Furthermore, what are the two "switches" if they happen -- from who1 to who2, then who2 to who3?

部分答案如下: http//www.haskell.org/pipermail/cvs-ghc/2011-May/062287.html (副本: http ://markmail.org/message/2q6fjthw2wvof244?q = switch + list: .haskell.cvs-ghc&page = 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM