4 ms·
There is very heavy integration between libdispatch and the kennel on macOS. In fact, when porting libdispatch to non macOS platforms for Swift on Linux, the de
by alblue 6y ago
There is very heavy integration between libdispatch and the kennel on macOS. In fact, when porting libdispatch to non macOS platforms for Swift on Linux, the developers were surprised that they couldn’t just unilaterally introduce changes into the Linux kernel in the same way that they had done on macOS itself.
As a result on Linux platforms, the libdispatch libraries are a software bolt on that doesn’t have the same level of tight integration (and therefore performance) than on macOS.
Given that libdispatch existed in macOS with kernel integration a long time before the Linux library port was added, your claim that it was cross platform doesn’t stand up. It was macOS first, with kernel integration, and then a separate compatibility layer afterwards for non-macOS platforms much later.
Source: I helped out with the porting of Swift to Linux when at Apple.
- Const-me 6y agoInteresting. Can you confirm OSX has thread pool support in the kernel, in a way that affects thread scheduling in a non-trivial way? Or is that kernel support only for message passing, callbacks, memory management, synchronization, logging or similar?
- alblue 6y agoThe issue is that dispatch needs to know what’s running and to allow for the threads to effectively work with the thread schedule to service dispatch in an appropriate way. On macOS, the implementation is done in kernel, although there is a front end user library that used to interact with it. This article, although a few years old, talks about the separation of the parts and goes to explain why it’s not a trivial port to other operating systems. https://gigaom.com/2009/09/14/apple-open-sources-grand-central-dispatch/ https://gigaom.com/2009/09/14/apple-open-sources-grand-centr...