| ▲ | MarkSweep 8 months ago | |
> suspending threads in your own process is kind of necessary for e.g. many GC algorithms True. Maybe the more precise rule is “only suspend threads for a short amount of time and don’t acquire any locks while doing it”? The way the .NET runtime follows this rule is it only suspends threads for a very short time. After suspending, the thread is immediately resumed if it not running managed code (in a random native library or syscall). If the thread is running managed code, the thread is hijacked by replacing either the instruction pointer or the return address with a the address of a function that will wait for the GC to finish. The thread is then immediately resumed. See the details here: https://github.com/dotnet/runtime/blob/main/docs/design/core... > Now imagine multiple of those runtimes running in the same process. Can that possibly reliably work? Sounds messy. | ||