18 ms·
I don't understand how Windows "gets this right" other than by accident. In the Win32 heyday it was in their interest to have you code against kernel32, advapi
by asveikau 8y ago
I don't understand how Windows "gets this right" other than by accident. In the Win32 heyday it was in their interest to have you code against kernel32, advapi, etc. so that your stuff works on 9x and NT, maybe CE. Now 9x/CE are gone and ntdll often has the "good" interfaces and the public wrapper APIs kind of lag behind. (Maybe ntdll itself having stubs and not telling the program to SYSENTER directly is the "good" design?) Meanwhile in the Linux world you have plenty of iteration on syscalls, you might say there is too much. They have to maintain cruft but OK.
libc as the boundary doesn't make sense either as glibc is not the Linux kernel, by design, and there are other libcs in common production, like in a billion Android phones.
- int_19h 8y agoIt's not just Windows that gets it right. The situation is the same on macOS, and on all the BSDs. The notion of userspace doing syscalls directly is really pretty much unique to Linux at this point. And no, you still can't use NTDLL on Windows - not unless you're doing (OS-specific) drivers. It might work in practice, but it also breaks sometimes, because there's no API stability guarantee.
- asveikau 8y agoIn those projects the libc is part of the tree. In Linux it is not the case. This is logically consistent for the project at hand. You can advocate a different way and I can agree but it wouldn't be Linux. (I am no stranger to BSD either. Been using *BSDs in some form for 19 years.) By the way Windows CRT ships new versions with Visual Studio out of devdiv... So Windows doesn't even work that way if you draw the boundary at libc. This is part of my comment, I don't understand which part of it is MS doing it right? Ntdll abstracting sysenter? Kernel and advapi abstracting ntdll? I don't think the latter example is one of great technical execution, it just sort of happened to promote compatibility with 9x and they're stuck with it.
- int_19h 8y agoBy "libc" I mean the userspace layer here broadly - on Windows that would be kernel32 etc. What VC++ calls CRT is built on that in turn. Although as of Win10, the actual CRT is also an API-stable OS-level component now, not a VC++-specific thing: https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/ https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introduci... The right thing here is the general notion of abstracting away core kernel APIs in userspace. It lets you refactor the whole thing significantly without breaking everything. And userspace calls are easier to maintain long-term for legacy support reasons, as well (at some point you can make it into a DLL that doesn't even have to be distributed with the OS, and just ship that with apps that need it).
- asveikau 8y agoDid you miss the part where I pointed out the reason to abstract ntdll is dead? There is no more 9x. There is no more CE. It would already be serious work to move away from NT. eg. Why should all the filesystem APIs be path-based and introduce an extra CreateFile with who-knows-what sharing flags behind the scenes, when NT was built to work with handles and path lookup is slower than on Unix? Abstractions are good but they need some basis in reality. The situation in Windows is in many cases layers atop layers without an actual need.
- int_19h 8y agoThe difference between ntdll and kernel32 is very different from the original discussion about syscalls. The reason why kernel32 is still there because there's tons of software written for that API. The reason why it's good to abstract away syscalls is because it allows you to break those syscalls without userspace noticing.