3 ms·
Since macos is based on mach & bsd, how do they keep things performant?
by woolvalley 8y ago
Since 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...
- ridiculous_fish 8y agoWell the importance of the kernel on application performance is often over-estimated, especially for non-server software. xnu is a hybrid of Mach and FreeBSD. To be super-concrete, it has both sets of syscalls, with Mach syscalls as negative integers, and BSD syscalls as positive integers. A given running executable has a dual existence as both a BSD pid_t and a Mach task_t. At one point it was even possible to have a Mach task without a pid. Most executed syscalls are BSD: read, write, select, getpid, etc. However Mach still plays a role in the VM system (`vm_copy`, etc.) and crucially via the IPC workhorse `mach_msg`. It's hard to overstate the importance of mach_msg. It underlies the great macOS IPC primitives: xpc, notify(3), etc. Linux looks anemic by comparison with its limited pipes, creaky SysV sendmsg(), and DBus (hope you never have to use it). But it also appears that Apple is preparing to drop Mach: mach_msg / MIG is buried, xpc is conspicuously designed to be separable from Mach, etc.
- ksec 8y ago>But it also appears that Apple is preparing to drop Mach: mach_msg / MIG is buried, xpc is conspicuously designed to be separable from Mach, etc. Why? What benefits do they have to drop it ?