by rickdeckard · 2y ago · 0 comments
> "Keep the greatest advantages of the NT™ architecture, while implementing new features and technologies known from other Operating Systems."
Wouldn't hurt to hear what the greatest advantages of the NT architecture are from the author's POV...
PyParallel: How we removed the GIL and exploited all cores -
https://news.ycombinator.com/item?id=7861942
The speaker's HN profile for additional commentary on this topic -
I really do like NT internals though.
When asked people point to IOCP vs epoll, but I'm not sure how relevant it is now that Linux has io_uring.
(They also point to stable ABIs for drivers, but I am more interested in internals)
https://windows-internals.com/i-o-rings-when-one-i-o-operati...
https://learn.microsoft.com/en-us/windows-hardware/drivers/d...
Yes, memory wasn't as plentiful back then and with single-core machines there still would've been more unavoidable context switches but with queues the context switches could've still been reduced in total as opposed to crossing the kernel boundary at all.
Now I use and like Linux and macOS and iOS, and I strongly dislike Windows. But I don't think I would find it difficult to find advantages to NT's approaches to certain problems over the UNIX-style approach to the same problems. For example, the idea that pipes send structured objects rather than text is interesting and has definitive advantages (and disadvantages) compared to UNIX's text-based pipe model. Its filesystem permissions layer is also way more flexible than UNIX's, with hooks for arbitrary programs to inspect file accesses, which has advantages (and disadvantages). And its GUI-first approach to everything, where everything is primarily configured through some GUI rather than a command line or text file, has obvious advantages (and disadvantages). And although I don't understand it very well (again, not a Windows user), what I hear from HyperV is pretty cool.
NT is super interesting as the only serious alternative to UNIX-style systems. There is value in studying it, even if I find the overall experience provided by Windows to be much, much worse than my Fedora desktop or my macOS laptop.
Maybe you are thinking about Powershell. Powershell is interesting (although in practice I find it not very practical to use), but is quite another subject than NT. It's really also its own segregated world, that relies on dotnet, that is really another platform than NT (although in the first place implemented on top of it, and of course there are some integrations)
Windows ACL are powerful in theory but hard to manage in practice. Look at this fine textual representation for example: "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)". Hum; at least ugo+-rwx you can remember it, and actually POSIX ACL are also easier to remember than Windows ACL.
Windows NT is not even that much GUI first. There are tons of things that you just can't access through a GUI, let alone a user friendly GUI. Funny example: ACLs on tasks from the Task Scheduler: no GUI access at all. It would probably not even be too hard for MS to plug their standard permission Window so that you can access them with the GUI, but they never did it. So much for the GUI first. Oh, I'm not even sure it has a command line interface to set the ACL there. Maybe just the Win32 API.
I also don't think there is an integrated Windows tool to view for examples the processes in a tree, even less to show Win32 jobs.
HyperV by itself has nothing revolutionary but there are a few interesting ideas that it can bring when integrated in a few Windows component (some security related sadly reserved to Entreprise version, because it is well known that in 2024 making good security architecture unreachable from the general public and SME is a brilliant idea). But compared to Qubes OS for example, it is very little. Oh there are also no Windows GUI to show HyperV states for these integration (as opposed with regular full system VMs)
Now I still think there are a few good ideas in NT, but the low level layers are actually not that far from Unix systems. It's closer than Cutler would admit. (In particular, there are not so much differences between "everything is a "file"" and "everything is an "object"", at least when you look at what Linux as done about "everything is a "file"" -- this is quite ironic because Cutler particularly disliked the "everything is a "file"" idea)
Because any ol’ Surface ships as a secure core pc which utilizes virtualization for memory security etc:
https://learn.microsoft.com/en-us/windows-hardware/design/de...
ABI for device drivers allows to add support for new hardware without recompiling the kernel.
First-class support for multithreading, Vista even added thread pool to the userland API.
Efficient asynchronous APIs for IO including files, pipes, and everything else. Linux only got this recently with io_uring, NT implemented IOCP decades go in version 3.5.
NT security descriptors with these access control lists and nested security groups are better than just 3 roles user/group/root in Linux. This makes launching new processes and opening files more expensive due to the overhead of access checks, but with good multithreading support it’s IMO a reasonable tradeoff.
Related to the above, CreateRestrictedToken kernel call for implementing strong sandboxes.
Good GPU support, Direct3D being a part of the kernel in dxgkrnl.sys. This enables good multimedia support in MediaFoundation framework because it allows applications to easily manipulate textures in VRAM without the complications of dma-buf in Linux.
Related to the above, GPU-centric 2D graphics (Direct2D) and text rendering (DirectWrite) in the userland API.
I’ll bite. POSIX permissions are lousy, and NT permissions are mostly worse. It’s way too easy to mess up, and it’s way too hard to specify a sensible policy like “only a specific user can access such—and-such path”. At least NT can restrict directory traversal.
S3 got it right when they deprecated object-level ACLs.
> This makes launching new processes and opening files more expensive due to the overhead of access checks,
fork() is terrible and slow. CreateProcess is overcomplicated, but creating a process directly is a vastly better design IMO.
> but with good multithreading support it’s IMO a reasonable tradeoff.
Huh? Linux has had proper multithreading support since NPTL, which was a long time ago. Windows, in contrast, didn’t have reasonable support for multithreading on systems with >64 CPUs until Windows 11:
https://learn.microsoft.com/en-us/windows/win32/procthread/p...
I assume this is related to the way that Windows leaks all kinds of bizarre threading details into the user ABI.
I will grant that Linux’s original threading was an abomination.
> Related to the above, CreateRestrictedToken kernel call for implementing strong sandboxes.
Eww. The Windows sandboxing scheme is IMO an overcomplicated mess. Seccomp is not particularly friendly, but it does exactly what it says on the tin, and I would be far more comfortable running untrusted user code under seccomp than under Windows restrictions from token, jobs, integrity, etc.
NT has ACLs for everything. Each handle (read: descriptor) has associated ACLs.
Also, each handle can be waited ("selected") with same system call. No select()/epoll() vs wait() distinctions. Nw Linux has timerfd and procfd and others, but NT had these from birth.
In some way NT is more UNIX ("everything is a file") than UNIX itself.
I’m not sure Cairo is comparable to Direct2D, the ecosystem is too different.
On Windows, Direct3D 11.0 is guaranteed to be available. Even on computers without any GPU (like most cloud VMs) the OS uses a decently performing software emulation called WARP. For this reason, Direct2D is designed from the ground up to use these shaders as much as possible, and it shows because hardware GPUs deliver way more gigaflops than CPUs. For example, on my computer D2D implements anti-aliasing on top of MSAA hardware.
Cairo is cross-platform, and Linux doesn’t have a universally available GPU API. Some Linux computers have GL 4.5+, some have GLES 3.1+ (both GPU APIs have approximate feature parity with D3D11) some others have none of them. For this reason, Cairo renders vector graphics on CPU. Some computers, with slow CPUs and high resolution displays, don’t have the performance to render complicated 2D scenes in realtime on CPU.
This may change some day once Vulkan support on Linux is ubiquitous, but that day is yet to come.
Like NT? It is in fact the UNIX-likes that are compelled into a fairly ancient stream-of-bytes model; NT (and Windows atop it) understands that data needs to have structure, and imposes structure on that data at an OS level; everything is a manipulable handle, rather than an opaque block of memory to be written to/read from, arbitrarily.
Each handle has security descriptor/ACLs, not only a files, and format is the same. Each handle can be waited for fr with same system call, and you could mix and match file, socket and process handles in same call.
And it doesn't help that UWP and C++/WinRT turned out such mess that even Microsoft own teams rather use Webviews than native UIs.
https://techcommunity.microsoft.com/t5/microsoft-teams-blog/...
https://blogs.windows.com/windowsdeveloper/2024/06/03/micros...
https://github.com/microsoft/microsoft-ui-xaml/discussions/9...