5 ms·
No, it's not true across OSes. Some OSes are fully open source, and some OSes don't provide their source code. There are OSes like MacOS where the core bits hav
by cbsmith 4y ago
No, it's not true across OSes. Some OSes are fully open source, and some OSes don't provide their source code. There are OSes like MacOS where the core bits have been open sourced to varying degrees over time.
Notably, Apple appears to not be updating the Darwin project the same way they once did, and the XNU kernel source code was last updated in mid-2021 (and pretty sparingly).
When I searched for os_unfair_lock_with_options, I didn't get any matches. Aside from some real-time Linuxy platforms where the kernel runs on top of a proprietary microkernel, you can find the source code for any Linux synchronization primitive.
- dagmx 4y agoMid 2021 lines up with the last major release of macOS…updates to the OSS repo happen after each major release. macOS Ventura has yet to release. So your complaint there seems misplaced
- cbsmith 4y agoIt's unsupported though. As you mentioned, minor version releases and security patches certainly don't get updated in it. I couldn't find os_unfair_lock_with_options in it (maybe I just missed it). AFAIK the only reason you can still build from the source is because of the work from volunteers. So, unless your target is Darwin, you can't be sure that the source is what your code is going to be interacting with. It's certainly a helpful starting point, but you do have to attempt to reverse engineer the interface to make sure you understand how it behaves.
- saagarjha 4y agoLast commit was earlier this year for a Monterey release: https://github.com/apple-oss-distributions/xnu https://github.com/apple-oss-distributions/xnu. The next one will almost certainly be for the first build of Ventura. Here is the header for the (private) function os_unfair_lock_lock_with_options: https://github.com/apple-oss-distributions/libplatform/blob/265976204fef993fd699fb97e874fcc9d5a95e4b/private/os/lock_private.h#L315 https://github.com/apple-oss-distributions/libplatform/blob/.... Synchronization primitives happen to be one of the things Apple is pretty good about releasing the source to.
- cbsmith 4y agoAhah! We were both looking in the wrong place, as we both only found the declarations, not the definition. With your pointer, I was able to find it though: https://github.com/apple-oss-distributions/libplatform/blob/265976204fef993fd699fb97e874fcc9d5a95e4b/src/os/lock.c#L613 https://github.com/apple-oss-distributions/libplatform/blob/... So perhaps I am wrong. I was always under the impression that you couldn't count on Darwin to be representative of how iOS/OSX work anymore, but maybe I'm wrong.