r/kernel • • 1d ago

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

28 comments sorted by

3

u/Lopsided-Dare-8119 1d ago

What is the precise definition?

-1

u/zotaxen 1d ago

Depends with definition you use. You can define after the Kernel-Mode or Kernellayer. So there is no real definition.

3

u/ScallionSmooth5925 1d ago

Then choose a definition state it somewhere and go with it

0

u/zotaxen 1d ago

I have I just want to now what other thinks and use it for my paper.

0

u/CubicleHermit 8h ago

Do your own homework, bro :)

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.

1

u/zotaxen 1d ago

Thank you for your massive explanation. It matches what I found out. I'm arguing against the idea of the hybrid kernel: you still have the kernel space, you just sorted it for better use. A hybrid system should be able to do what a microkernel and a monolithic kernel can do at the same time. This is only possible if there is a master in the kernel that moves the pieces in and out.

3

u/arbv 1d ago

IIRC, GUI is in user-space again since Vista times.

3

u/zeldaink 1d ago

Yeah. WDDM introduced the split model. The parts that work with the hardware are in kernel mode and the parts that work with DirectX are in userspace. DX itself is split in the two modes - the bit that talks to the driver are in kernel and expose interfaces to the low-level userspace DX.

Like on Linux DRM is the subsystem, amdgpu is the kernel mode driver, libdrm talks to amdgpu, mesa is DX and radeonsi/radv are the usermode driver, but libdrm doesn't exist and is entirely handled by DRM in kernel, and nothing will work without mesa.

2

u/arbv 1d ago

That is exactly what I had in my mind when writing the comment. Thanks for going into more details.

2

u/msthe_student 1d ago

Part of it. Also the graphics-drivers are largely user-space, which is why you can have them crash without taking the whole system down for example

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!

2

u/zotaxen 1d ago

Thanks, my prof told me to read it to, I'm trying to get it from my library.

2

u/Kautsu-Gamer 20h ago

Win XP was monolithic, which caused problems on NTs as almost everything was developed for XP.

3

u/CubicleHermit 8h ago

XP is literally just NT 5.1 (5.0 was 2000; 5.2 was server 2003.)

Windows NT 4 relaxed some of the microkernel-like subsystem boundaries around the GUI system for performance reasons; 3.1-3.51 still kept a client/server boundary between the GUI subsystem and the kernel.

If you mean Windows 95/98/ME not XP, those were... architecturally weird, and were hybrid OSes in a completely different way since they booted on top of DOS and still had a lot of 16-bit Windows underpinnings.

1

u/Kautsu-Gamer 28m ago

Ah. Then the limit was Win98.

Windows ME was never officially published - for a really good reason. Microsoft has removed all notions of that blunder from their sites

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:

  • The NT kernel was originally written to be a microkernel.
  • The internal APIs still make it easy to move components into and out of the kernel.
  • Originally a lot of "kernel things" were outside the kernel, and got moved inside the kernel for performance reasons.
  • Today there's a whole user-mode driver scheme.
  • Might be worth looking up the "library OS" papers from MSR, and how they were basically making Win32 containers by (IIRC) running a bunch of copies of the Win32 API in user mode.

2

u/Kautsu-Gamer 20h ago

It was marketing for 10 and 11, as Win7 was last NT for users. Windows servers are NTs.

2

u/phoenix_frozen 19h ago

... I don't think that's true. Windows server and client do not use different kernels. 

2

u/Kautsu-Gamer 17h ago

I may be mistaken, but Win10 relaxed kernel restriction. You are likely corrent, and I do have mistaken.

I did not know they use same kernel. The desktops share same kernel.

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.

2

u/CubicleHermit 8h ago

2000/XP/Vista are all also NT. The non-NT line died after Windows ME.

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.