This sounds very similar to Cuzz from Application Verifier for Windows:<p><a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/application-verifier-tests-within-application-verifier#cuzz" rel="nofollow">https://learn.microsoft.com/en-us/windows-hardware/drivers/d...</a>
It is possible to do this entirely in userspace without a custom scheduler.<p>See the implementation here: <a href="https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/ThreadFuzzer.h">https://github.com/ClickHouse/ClickHouse/blob/master/src/Com...</a><p>It works and makes significant improvements for the detection of concurrency bugs, including complex logical races in distributed scenarios.