Hacker News new | ask | show | jobs
by kstenerud 2335 days ago
What purpose would locks and concurrent primitives have in a system where running code is not preempted?
2 comments

In addition to parallel in all senses/levels systems mentioned by the other commenter, another example would be a truely single threaded hardware with cooperative or even sequential multithreading where you'd use locking/etc. to safeguard your memory model invariants against for example compiler, JIT and hardware optimization shenanigans.
To guarantee two different threads don't try to simultaneously mutate (or in some cases access) shared resources.