Ported from https://github.com/google/periph/issues/185. This one is risky, since it assumes a lot from the Go own scheduler.