3 ms·
> Systems stopped using cooperative multitasking at least 20 years ago because it sucked compared to the alternative of automatic, preemptive multitasking. And
by kazinator 12y ago
> Systems stopped using cooperative multitasking at least 20 years ago because it sucked compared to the alternative of automatic, preemptive multitasking. And yet Node.js harks back to those dark days with its callback-based concurrency, all running in a single thread.
Uh, no. For instance, Unix kernels have been traditionally cooperative---at least when executing kernel code. That is to say, user space can be preempted but not the execution of kernel code. The introduction of SMP brings concurrency into the kernel, though, and with that, preemption can follow. Linux development followed this path.
Still today, you don't have to turn on CONFIG_PREEMPT when building your kernel. If you don't have SMP either, then you have a cooperative kernel: one task is in there at a time, and it has the CPU until it voluntarily calls into the scheduler.
Cooperative tasking has the enormous advantage that it makes a whackload of potential race conditions go away, and that could be a possible reason why Node.js is the way it is.
Unix might not have been successful had Ken Thompson decided to make the kernel preemptive, and then spent 1973-1987 debugging it. :)
- pjmlp 12y ago>Unix might not have been successful had Ken Thompson decided to make the kernel preemptive, and then spent 1973-1987 debugging it. :) Sadly that didn't happen, UNIX was adopted by 80's hipsters into their startups, became adopted by the industry at large, thus spreading C into the industry. Now we have patch <choose day of week>.
- rjblackman 12y agopeople working on computers in the 80s were not hipsters.
- pjmlp 12y agoThe persons called hipsters in computer culture already exited back then, we just didn't called ourselves hipsters. The remark was for the younger readers. Me, I was into the demoscene and couldn't care less about UNIX until around 1993.
- cben 12y agoI'll bite. When I learnt C I found it charmingly simple and it took me years to realize how deeply broken some aspects are, especially the separate compilation circus — programmers working hard to help the compiler and not getting any modularity benefits in return. So suppose C didn't happen. Do you expect the industry at large would have adopted a great language instead? Or some random product of history, half way between PL/I++ to JavaScript?
- kazinator 12y agoEnforced modularity in languages has downsides, like basically killing the flexibility in system construction. Not every image produced is an application program running over an operating system.