3 ms·
I agree with the author's complaint about the problems of Wikipedia being taken as authoritative on operating systems. I have seen all kinds of bizarre claims w
by naleshniki 2y ago
I agree with the author's complaint about the problems of Wikipedia being taken as authoritative on operating systems. I have seen all kinds of bizarre claims which are at odds with reality, but which, being described in a wikipedia page, are taken for gospel, and end up reproduced and sometimes embellished further.
His article is probably quite a good discussion of what happens on Linux. It is over-reaching however if it is supposed - as it seems to be in the conlusions - to be talking about modern Unix-likes generally.
PID 0 on NetBSD (and I suspect of Free, DragonFly, Open, etc, as well) simply means the kernel process. Here are a few of the threads that run under the kernel process in NetBSD:
PID PPID CPU LID NLWP PRI NI VSZ RSS WCHAN STAT TTY LTIME COMMAND
0 0 0 118 106 123 0 0 28132 physiod DK- ? 0:00.00 [system]
0 0 0 117 106 125 0 0 28132 pooldrai DK- ? 0:00.00 [system]
0 0 0 116 106 124 0 0 28132 syncer DK- ? 0:00.00 [system]
0 0 0 115 106 126 0 0 28132 pgdaemon DK- ? 0:00.00 [system]
These are all true and authentic threads, they just don't spend any time executing userland code. The work they carry out is, respectively: to carry out I/O to/from buffers in userland, because this may incur page faults and cannot therefore be done in a soft interrupt which has no thread context; to reclaim pages from the pool (slab) allocator; to lazily synchronise dirty buffers back to disk; and to carry out page replacement.
All of these listed above carry out memory management, so it is not correct to say that PID 0 "has nothing to do with memory management" or that the Wikipedia article is wrong to discuss paging as a responsibility of PID 0. That's what pgdaemon is doing!
There are many other threads that are part of the kernel process (or "PID 0") on NetBSD - modern kernels generally use a lot of them to carry out all sorts of tasks. A few others on NetBSD include worker thraeds for running asynchronous I/O completions and for processing various kinds of input in the networking stack.
Illumos should also be considered. Looking at its PID 0:
root 0 0 1 1 0 11:22:53 ? 0:02 sched
We can see it is called sched. Why sched? This article talked about the historic role of PID 0 in process swapping. Process swapping is a scheduling problem (like a lot of problems in software). This is why swappers are traditionally called medium-term or memory schedulers. Illumos generally gives most groupings of kernel worker threads their own processes with their own PIDs, but one, called "sched", remains in PID 0, and its responsibility? Process swapping:
https://github.com/illumos/illumos-gate/blob/579c23696ac68911e4483760cb3224a2c161a691/usr/src/uts/common/os/sched.c#L142 https://github.com/illumos/illumos-gate/blob/579c23696ac6891...
The Wikipedia article has now been hastily edited, and replaces a claim that was true only of certain Unixes other than Linux with a claim true only of certain Unixes including Linux. Is this an improvement?
- wizzwizz4 2y ago> I have seen all kinds of bizarre claims which are at odds with reality, but which, being described in a wikipedia page, are taken for gospel, and end up reproduced and sometimes embellished further. Editing Wikipedia is fun, but sometimes it is hard to know where to edit. Here's a simple process to find correctable errors! (1) Sneak onto your local university's campus. (2) Sit in any operating systems lecture. (3) Watch for nonsense in the slides. (4) Locate the relevant Wikipedia page. (5) Rewrite the entire two-page section around whatever was on that slide, because chances are it's all nonsense.