Microkernels are slow and Elvis didn't do no drugs
Good IPC requires tight coupling between the IPC mechanism and the scheduling mechanism.  In QNX, you call MsgSend, which sends a message and blocks.  On the receive side, a process waiting in a MsgReceive gets the message and unblocks.  The fast path for this, when there&#x27;s a thread waiting for a message, does not go through CPU dispatching or CPU switching on a multiprocessor. This is crucial to performance.<p>You do pay a penalty for copying. For short messages, it&#x27;s low. For anything that fits in cache, that you just created and will use immediately on the receive side, it&#x27;s very low.  Really big messages may add 10%-20% overhead.  This is the main problem with drivers in user space, because they don&#x27;t do anything with the data, they just move it around.<p>Incidentally, copying under QNX is preemptable by high-priority tasks. There&#x27;s a hard upper bound on the longest uninterpretable kernel operation, and it&#x27;s measured in microseconds.  That&#x27;s why you can use QNX for hard real time.<p>Contrast what happens on Linux. You have a few choices (System V IPC, pipes, sockets), but they all work like I&#x2F;O operations. You send something, and you don&#x27;t block when you do.  If there&#x27;s someone waiting on the queue or pipe, their thread becomes active, which means a trip through the scheduler to get them going.
Since the sending thread isn&#x27;t blocked, if there&#x27;s a free CPU, the receiving thread starts up on a different CPU, which means lots of cache misses.  The sending thread probably blocks shortly after the send by reading something or waiting for a message, but the OS doesn&#x27;t know that&#x27;s going to happen.  So when it does, there&#x27;s another trip through the dispatcher for work to do.<p>In a compute-bound environment, this may mean that each IPC operation sends you to the end of the line for CPU time.  Trying to use IPC operations like subroutine calls is painfully slow in such systems.<p>Write something that does short IPCs and waits for replies, and benchmark it. Then add some compute-bound tasks, enough to keep all the CPUs busy.  If the IPC task performance drops by orders of magnitude, the IPC mechanism is badly designed.<p>L4 is very impressive, but I think they went a little too far by using shared memory as the main interprocess communication mechanism. This gets copying out of the kernel, but means that one process can screw up the format of the memory region it shares with another process. The OS may be robust and secure, but attacks on the process you&#x27;re talking to by messing with pointers in the shared area may be possible.<p>The big problem with QNX is that it costs money. Linux is free, and Windows is basically given away with hardware and trialware.<p>I hope that someone writes a QNX-like microkernel in Rust. We need that.