logoalt Hacker News

zbentley • today at 1:18 PM • 0 replies • view on HN

I do think they’re fundamentally different, for two reasons:

1. The decision of when to switch routines is more consequential than the cost of stack or context switching. Letting the OS decide results in behavior that is consistently fair for all programs, caveat scheduler bugs. Letting user code decide results in behavior that is only as fair as a given program. Writing code in the latter environment entails wrestling with the reality that it may not run to completion unless other code in the environment lets it. That applies in async programming to a much wider range of situations than kill signals/aborts, which are the only even slightly analogous things in threaded programming.

2. Async is a subset of threaded programming (it has a hardware stack, and can call typical context-switchful code if it wants to block).