Is Windows NT really a hybrid kernel? (question for my term paper)
Hi! I'm writing a term paper for university comparing the Linux and Windows kernels. I'd like to hear your opinion on the idea of a hybrid kernel. Do you think Windows NT really is one, or is it basically a monolithic kernel, as Torvalds once said ("it's just marketing")?
24
Upvotes
3
u/Lopsided-Dare-8119 1d ago
What is the precise definition?
9
u/zeldaink 1d ago
The graphics subsystem at one point worked in user mode and after seeing how bad it performed, got shoved to kernel mode.
Apart from that, Win32, POSIX and OS/2 (later two got removed) run mostly in user space. There is the Executive that runs in kernel space. It's EXTREMELY restricted. You can't do much with it, but you can boot to it with specific windows server variants (forgot which were). This is the native NT API. You aren't meant to interact with it, drivers typically use it. It lives in ntdll.dll and ntoskrnl.exe. You interact with Win32. csrss.exe provides you the userspace portion of the Win32 API, along side kernel32.dll, user32.dll, gdi32.dll etc.
That ntdll.dll file is kinda special. It runs in kernel space, but can be called just fine in user space. Not by you but by Win32. The NT Executive runs on top of a microkernel. That's the true NT kernel. Every other NT subsystem works above it. The drivers run alongside that microkernel "layer". Both the microkernel and the drivers are above the HAL (hal.dll), which is the thing that actually interfaces between the hardware and the NT kernel. The thing is so spread across so many files, that you loose track of what is what and what it does. Sorta kernel within a kernel. Basically L4Linux, but the entire thing is a kernel.
Technically, NT can pretend to be Linux or even BSD, alongside Win32. No emulation or virtualization required. It just needs the respective equivalent of the Win32 bits and it can run Linux or BSD apps natively. That's called "Personality". Win32 is NT's primary personality. POSIX and OS/2 personalities existed back in the days. WSL 1 is more of a Linux personality, while WSL 2 is pretty much Linux on Hyper-V VM.
NT lives in kernel space and has bits in userspace. It's very convoluted mess for a reason. By design, it's monolith/microkernel hybrid. In practice, it's monolithic with modules. Most of what makes the kernel a kernel lives in kernel mode. Few bits are exposed to the user mode.
Oh, and windows uses x86 rings 0 and 3. Few driver are bothered to use rings 1 and 2. All the crap runs in kernel mode with some of it is sticking out in the userspace. I don't think Linux uses rings 1 and 2 at all. Only OS that has use of those two rings is OS/2.
You really need a diagram in front of you to see how this insanity is organized and why it's hybrid by design and for all intents and purposes, it's monolith with modules.
3
u/yunke13 1d ago
I might be wrong here, so please take this with a grain of salt, but as far as I know NT is closer to VMS in its design, and it isn't a monolithic kernel. It's usually described as a hybrid kernel. That label is debated though, as a lot of it runs in kernel space.
If you're curious, I'd humbly recommend "Showstopper!" by G. Pascal Zachary. It tells the story of how NT was built and what the team went through to get it done.
Happy to be corrected by anyone who knows more!
13
u/eteran 1d ago
Windows does have some user mode drivers, so I guess technically it's a hybrid kernel. But then again, Linux has fuse, so you could say the same thing there too.
7
u/nhermosilla14 1d ago
Definitions are everything for this kind of question. If your definition is as wide as "there's at least one driver running in user space", then yes, it's a hybrid kernel. Now, if you make it mandatory to have some category of drivers running in user space and some others in kernel space, I don't think Windows is that strict about that.
2
u/TTachyon 1d ago
NT is a hybrid kernel the same way Linux way. Technically, Microsoft provides some support to write userspace drivers, but fuse is also a thing that's heavily used on Linux. So, which one is more hybrid?
I don't think there's a right answer, but neither feel very hybrid to me.
2
u/monocasa 1d ago
It's a hybrid kernel kind of like XNU. The executive is the equivalent to Mach's use in XNU.
2
u/phoenix_frozen 23h ago
This is complicated. I understand why Torvalds says "it's just marketing", but I don't think that's right. It is, these days, mostly a monolith, but not for lack of trying.
The highlights:
2
u/Kautsu-Gamer 20h ago
NT was a hybrid of Windows and VMS. Most of NT developers were former VMS developers.
2
u/Kautsu-Gamer 20h ago
Unlike XP, NT runs mostly in user space. This was main cause of the compatibility issues as Win32 did use kernel calls when developed for Win XP.
Main reason of slowness of Win7 is caused by this separation as Win 7 was NT.
1
u/kitsnet 1d ago
Windows NT has a native NT kernel API and runs Win32/Win64 wrappers for the NT API in user mode, while Linux syscalls are processed directly by the kernel.