| ▲ | hyperpape 8 months ago | |||||||||||||
> suspending threads in your own process is kind of necessary for e.g. many GC algorithms I think this is typically done by having the compiler/runtime insert safepoints, which cooperatively yield at specified points to allow the GC to run without mutator threads being active. Done correctly, this shouldn't be subject to the problem the original post highlighted, because it doesn't rely on the OS's ability to suspend threads when they aren't expecting it. | ||||||||||||||
| ▲ | achierius 8 months ago | parent [-] | |||||||||||||
This is a good approach but can be tricky. E.g. what if your thread spends a lot of time in a tight loop, e.g. doing a big inlined matmul kernel? Since you never hit a function call you don't get safepoints that way -- you can add them to the back-edge of every loop, but that can be a bit unappetizing from a performance perspective. | ||||||||||||||
| ||||||||||||||