Recently a friend and fellow programmer asked me how I learn a new language or platform. I answered that I do it with specific task in mind. Basically, I bumble along googling every little step until I complete my task. But I forgot to tell her about the pitfall of this method…
(This is a sort of simplified retelling of http://fdiv.net/2011/01/14/machportt-inter-process-communication with some added lore. You should probably start there.)
Much of the magic behind macOS and iOS (and all the derived xOSs - watch, appleTV, the stripped down versions in cables and touch bars and wherever else these things invariably end up) is performed with the assistance of other processes (including the kernel). Communicating between them is accomplished by various ways, but for macOS, the underlying mechanism is a client/server IPC mechanism powered by Mach, and the underlying currency is the mach port (
During my time at Apple, I dealt with a lot of rather low-level systems treachery. It’s poorly documented, even internally, and asking for help has roughly even odds on getting a passive aggressive non-answer.
The cool trick for today is creating a “memory object.” A memory object is one or more physical pages that are wrapped in a mach port. With this, you can pass the port to another process, who can map the pages, creating shared memory. Or you can map the pages again in your own address space, to create a mirror, or with different permissions so you can expose read-only pages at an interface boundary while still having the pages be writable at a different address.
Vienna in the 1840s was a scary time and place to give birth. From 1840 to 1846, 7% of women who gave birth at the Vienna General Hospital died of a postpartum infection called childbed fever. One doctor at the hospital, Ignaz Semmelweis, made it his mission to stop the disease. His work saved hundreds of lives, contributed to the development of medical hygiene — and can teach us a few things about debugging.