5 ms·
In QNX, everything is a message, including files. The basic primitive is MsgSend, sent to another process which has a MsgRecv outstanding. The other process sen
by Animats 8y ago
In QNX, everything is a message, including files. The basic primitive is MsgSend, sent to another process which has a MsgRecv outstanding. The other process sends a reply back with a MsgReply, which unblocks the MsgSend and returns data. Any amount of data can be sent. POSIX file primitives, open/close/read/write, are small functions that make MsgSend calls.
MsgSend is a more useful primitive than a file. It's a subroutine call across processes, a better fit to anything that isn't stream I/O. In most OSs, you want a subroutine call, but the OS gives you an I/O operation. Linux has to stand on its head for operations such as getting all the properties of a pluggable device, because returning a variable length array of fixed-format records as an atomic operation isn't a Linux primitive.
Microkernels have a bad reputation because interprocess communication in Mach was botched. Mach was built on BSD. To do this right, you have to design CPU scheduling and message passing together, and they need to be tightly coupled. The key to interprocess communication is arranging the normal path for a message pass to throw control from one process to another without a trip through the scheduler. Get that wrong and your microkernel will be sluggish.
- the8472 8y agoWell, on linux you can also sendmsg files between processes, by using files (unix domain sockets). So you can sendmsg everything. Even memory (memfd)
- _wmd 8y agosendmsg isn't a synchronous operation, and there is no lock-step operation of sender and receiver supplying and retrieving a result. Sure you can make something QNX-like, but parent's point was much more general than that: most OS APIs and primitives are not easily expressed in terms of bytestreams
- Animats 8y agoYes, and when you express them as bytestreams, you end up with framing and marshalling and serialization. People start sending JSON. Then they want to put everything in one process because the performance is so low.
- woolvalley 8y agoSince macos is based on mach & bsd, how do they keep things performant?
- berti 8y agoThey pulled some of the low-level I/O drivers into the kernel because the IPC overhead was too great. They call it a "hybrid" kernel rather than a pure microkernel.
- glhaynes 8y agoTo my understanding (please correct if wrong!) it's not only drivers, it's most of a BSD-style kernel that XNU runs in the same memory space as Mach. I'm not sure what difference that makes in practice versus the more conventional BSD kernels — I think a lot of IPC happens through Mach ports? … and I think Mach shows in the realms of signal delivery, what resources are waited on with `select`, etc.
- berti 8y agoYep, my understanding aligns with yours. Mach ports are the IPC mechanism for anything outside kernel address space.
- AlphaSite 8y agoFrom what I remember Mach ports aren’t even used much anymore.
- berti 8y agoI was thinking kernel to/from outside kernel IPC, sorry for the ambiguity. Some documentation can be found at https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/Mach/Mach.html#//apple_ref/doc/uid/TP30000905-CH209-TPXREF104 https://developer.apple.com/library/archive/documentation/Da...
- 8y ago
- gerdesj 8y agoIn QNX That's nice but what has that to do with this article about Linux?
- thom 8y agoWhat current work (that might have a hope of becoming mainstream for some subset of devices) do you see that does this well?
- TheDong 8y agoBinder on android shares some similarities. It's a low level RPC mechanism, it does reschedule to the new process immediately without a trip through the scheduler when it's used, it has similar blocking semantics, etc. It's also worth following the "bus1" work for linux which may end up being quite similar as well.
- Retr0spectrum 8y agoQNX itself had a hope of becoming mainstream as the core of Blackberry 10 OS. Unfortunately, Blackberry has moved over to Android these days.
- jschwartzi 8y agoQNX is mainstream as hell, just not anywhere you'd expect there to be an OS. It's an RTOS and gets used in automotive, medical, and network technologies where software latency needs to be tightly controlled. You wouldn't use it in the same place you'd use Linux anyway.
- thom 8y agoThis is true. I suppose I'm just curious about more general (server/desktop/mobile) use cases, because the IPC and scheduling issues the parent mentions must be extremely difficult to predict with a wide array of workloads.
- lsaferite 8y agoI remember using the single disk QNX demo back in the day and being highly impressed with the functionality the crammed into that disk. Sad that it never went anywhere as a desktop/server OS.
- EGreg 8y agoYou sound like a guy who geeks out and cares about architectural issues and trade-offs. You sound like I do when I write about open source and decentralized systems, web based and the latest crypto alternatives. Unfortunately that usually means you’ll get downvoted as people will claim you are violating this or that heuristic they just take for granted. Or have a distaste for your self-assured stances where you focus on substance and major factors instead of authorities and stuff that only sounds good on the surface. Sound familiar?
- nurettin 8y agoA post of you claiming that you've been downvoted for this or that reason usually gets downvoted. That is the only familiar thing.
- EGreg 8y agoWell yes, that one is obvious. But look at my history of the past, let's say, 10 or 15 comments, you will see the same pattern.
- sctb 8y agoIf you won't stop breaking the guidelines, we'll ban the account. > Please don't comment about the voting on comments. It never does any good, and it makes boring reading. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- JumpCrisscross 8y ago> MsgSend is a more useful primitive than a file Are they symmetrical philosophies? As a layman, this appears to mirror the financial debate between everything being stocks (“the quantum of an economy is a dollar of assets!”) and everything being flows (“the quantum is a transaction!”), or physics’ particle-versus-wave formulations.
- DonHopkins 8y agoLike the old cursor debate: Is the cursor ON a character, or BETWEEN two characters?
- Roritharr 8y agoYou've just pushed me into 20 Minutes of silent pondering and arguing with myself. My girlfriend asked me if something bad happened because I was just staring wordlessly into the air. Thanks for opening me up to this issue.
- nojvek 8y agoI believe most modern ui clearly communicates that it’s between by putting the cursor “in between” two characters.
- DonHopkins 8y agoOf course "vi" has all its bases covered, by alternating between the cursor being between two characters in "insert" mode, and over one character in "normal" mode: https://unix.stackexchange.com/questions/11402/why-does-esc-move-the-cursor-back-in-vim https://unix.stackexchange.com/questions/11402/why-does-esc-... >Why does `ESC` move the cursor back in vim? >In insert mode, the cursor is between characters, or before the first or after the last character. In normal mode, the cursor is over a character (newlines are not characters for this purpose). This is somewhat unusual: most editors always put the cursor between characters, and have most commands act on the character after (not, strictly speaking, under) the cursor. This is perhaps partly due to the fact that before GUIs, text terminals always showed the cursor on a character (underline or block, perhaps blinking). This abstraction fails in insert mode because that requires one more position (posts vs fences). >Switching between modes has to move the cursor by a half-character, so to speak. The i command moves left, to put the cursor before the character it was over. The a command moves right. Going out of insert mode (by pressing Esc) moves the cursor left if possible (if it's at the beginning of the line, it's moved right instead). >I suppose the Esc behavior sort of makes sense. Often, you're typing at the end of the line, and there Esc can only go left. So the general behavior is the most common behavior. >Think of the character under the cursor as the last interesting character, and of the insert command as a. You can repeat a Esc without moving the cursor, except that you'll be bumped one position right if you start at the beginning of a non-empty line. Also: https://superuser.com/questions/242156/make-vim-normal-mode-cursor-sit-between-characters-instead-of-on-them https://superuser.com/questions/242156/make-vim-normal-mode-... >Make VIM normal-mode cursor sit between characters instead of on them >I would really like it if the VIM cursor in normal mode could act like it does in insert mode: a line between two characters. So for example: >- Typing vd would have no effect because nothing was selected >- p and P would be the same >- i and a would be the same >Has anything like this been done? I haven't been able to find it. >Answers: >The idea that the cursor is always on a line and on a character position or column is inherent in Vim's design. If you were to try to change that, many of Vim's operations would behave differently or would not work at all. It's not a good idea. My advice would be that you learn and become accustomed to Vim's basic behavior and not try to make it behave like some other editor. – garyjohn Feb 5 '11 at 23:55 >What you want is not Vim, I'm afraid. – romainl Feb 6 '11 at 7:15 And people wonder why I still use Emacs...