Appearance
2.9.1 — The NT and Darwin Kernels
The photo-upload service runs on Linux servers. But the engineers who write it work on Windows and Mac laptops. Here is the service asking which operating system it is running on, on one of those laptops:
ts
// which-kernel.ts — the upload service asks which operating system it is running on
import { platform, type, release, arch, EOL } from "node:os";
import { delimiter, sep } from "node:path";
console.log("platform:", platform()); // (1)
console.log("kernel: ", type(), release()); // (2)
console.log("cpu: ", arch());
console.log("path separator:", JSON.stringify(sep), " PATH list separator:", JSON.stringify(delimiter)); // (3)
console.log("line ending:", JSON.stringify(EOL)); // (4)
// Printed on a Windows 11 laptop:
// platform: win32
// kernel: Windows_NT 10.0.26300
// cpu: x64
// path separator: "\\" PATH list separator: ";"
// line ending: "\r\n"
//
// On a Linux server the same lines read: linux · Linux 6.x · x64 · "/" and ":" · "\n"
// On a Mac: darwin · Darwin 24.x · arm64 · "/" and ":" · "\n"(1)Node's name for the platform.win32is a historical name and is used for 64-bit Windows too.(2)The kernel's own name. On Windows it saysWindows_NT: every version of Windows since XP is built on the kernel Microsoft started in 1988, called Windows NT. On a Mac it saysDarwin.(3)Windows separates folders in a path with\and entries inPATHwith;. Linux and macOS use/and:.(4)Windows ends lines of text with two characters, carriage return and line feed,\r\n. Linux and macOS use one,\n. Both habits go back to the teletypes of 2.8.2, where "carriage return" moved the print head back and "line feed" moved the paper up.
Those small differences are real, and section 4 shows how they break things. But underneath, all three systems do the same job in the same way. This page opens the Windows and macOS kernels and maps every concept from Part 2 onto them. By the end you will see that the operating system you studied through Linux is the same machine everywhere, with different names on the parts.
1. Windows NT: a different family tree
The Windows you use today does not descend from MS-DOS, the simple single-program system of the 1980s. Older Windows versions, up to Windows ME in 2000, were built on top of DOS. Modern Windows comes from a separate project started at Microsoft in 1988 and led by Dave Cutler, who had previously designed the VMS operating system at Digital Equipment Corporation. It shipped in 1993 as Windows NT, where NT stood for "New Technology". Windows XP, in 2001, brought the NT kernel to home computers, and every version since, including Windows 10 and 11, is NT underneath.
A hybrid kernel
2.1.1 described three ways to divide a kernel: monolithic like Linux, microkernel like QNX, and hybrid. NT is the standard example of a hybrid kernel. It is organised in clear layers, as a microkernel is, but almost all of them run in kernel mode, as a monolithic kernel does.
- The Executive is a set of managers, each doing one job you already know:
- The object manager is the most distinctive part. In NT, almost everything the kernel manages, a process, a thread, an open file, a lock, a registry key, is an object, with a type, a name and access rules.
- The small kernel layer handles scheduling and interrupts.
- The HAL, hardware abstraction layer, hides the differences between motherboards from the rest of the kernel.
Just as on Linux, programs reach the kernel only through system calls (2.1.2). On Windows those wrappers live in ntdll.dll, and, as that page noted, Microsoft changes the system call numbers between versions, so programs must always go through the library.
Handles: Windows's file descriptors
When a Windows program opens a file, it gets back a handle: a small number that indexes the process's table of open objects, exactly like a Unix file descriptor (2.1.2). The difference is breadth. A handle can stand for any object: a file, a process, a thread, a lock, a registry key. Task Manager's "Details" tab can show how many handles each process holds, and a steadily rising count is the Windows version of the descriptor leak in 2.8.3.
Subsystems, and the two kinds of WSL
NT was designed so that different personalities could sit on top of one kernel, each giving programs the interface of a different operating system. These were called environment subsystems. The early versions shipped with three: Win32, a POSIX layer for Unix-style programs, and OS/2. Only Win32 survives as the face of Windows.
That design returned with the Windows Subsystem for Linux, WSL, which lets you run real Linux programs on Windows. It exists in two very different versions, and it is worth knowing which is which.
- WSL 1, released in 2016, followed the old subsystem idea. A Linux program's system calls were caught by a Windows driver and translated into the NT kernel's own operations. No Linux kernel was involved. It worked surprisingly well, but some Linux features never translated cleanly, and file access was slow.
- WSL 2, announced in 2019 and released in 2020, takes a completely different approach. It runs a real Linux kernel, built by Microsoft, inside a small, fast-starting virtual machine on Windows's built-in hypervisor (14.1.2). Linux programs talk to a genuine Linux kernel, so everything works, including Docker. That is why Docker Desktop on Windows uses WSL 2.
2. How Windows maps onto everything in Part 2
Here is the table that turns Linux knowledge into Windows knowledge. The ideas are the same; the names and some details differ.
| Idea | Linux | Windows |
|---|---|---|
| Open thing a program holds | file descriptor | handle |
| Create a process | fork then exec | CreateProcess, in one step |
| Ask a program to stop | SIGTERM | console control event, or a window message |
| Force it to stop | SIGKILL | TerminateProcess |
| Swap area | swap partition or file | page file, pagefile.sys |
| Resident memory | RSS | working set |
| First process / service manager | systemd | smss.exe, wininit.exe, Service Control Manager |
| Live system information | /proc | performance counters, WMI |
| Readiness/completion I/O | epoll, io_uring | I/O completion ports |
| File system | ext4 | NTFS (2.6.3) |
A few rows deserve a sentence each.
No fork. Windows has no equivalent of fork (2.2.2). CreateProcess takes the name of a program file and a large structure of options, such as which handles to pass on and where its standard streams go, and starts the new program in one call. Everything the Unix child would set up in the gap between fork and exec is passed as an option instead.
No real signals. Windows does not have Unix signals (2.2.3). A console program can receive a few control events, such as Ctrl+C or the console window closing. A program with a window receives messages asking it to close. A service is told to stop by the Service Control Manager. And TerminateProcess ends a process immediately, like SIGKILL. That is why Node on Windows can catch Ctrl+C as SIGINT, but cannot receive a real SIGTERM from another process, as the graceful-shutdown demo noted.
Threads first. NT was designed around threads from the start. Its scheduler picks threads, using 32 priority levels, and gives a temporary boost to threads in the window you are using, so the program in front of you feels responsive. That is the same goal as the multi-level feedback queue of 2.3.2, reached a different way.
Completion ports. Windows's main high-performance I/O interface, I/O completion ports, is completion-based, like io_uring (2.7.3), and has been since the 1990s. Node's library libuv uses them on Windows, which is how the same Node code runs efficiently on both systems.
3. macOS: a Unix underneath
macOS is closer to Linux than it looks. Its core, called Darwin, is open source, and its kernel is called XNU, which stands for "X is Not Unix", although it is one. XNU is itself a hybrid of three parts:
- Mach, a microkernel developed at Carnegie Mellon University in the 1980s, which provides tasks, threads, virtual memory and message passing between programs.
- A BSD layer, taken from the FreeBSD family of Unix, which provides processes, users, permissions, Unix signals, sockets and the file system interfaces. This is what makes macOS a Unix.
- I/O Kit, the framework that device drivers are written in.
Because of the BSD layer, everything in this Part works on a Mac almost unchanged: fork and exec, signals and graceful shutdown, pipes, file descriptors, the shell and its streams, ps and top. Since 2007, macOS has been officially certified as a UNIX system. The main differences you will meet are these:
- The first process, PID 1, is
launchd, notsystemd. It plays the same role: starting and supervising services, described by small configuration files (2.8.4). - There is no
/proc. Tools such aspsandtopask the kernel through system calls instead. kqueuetakes the place ofepollfor event loops (2.7.3).- The file system is APFS, normally ignoring upper and lower case (2.6.3).
- Since 2020, Macs use Apple's own ARM processors, so the CPU line in the opening demo says
arm64.
That combination, a friendly desktop with a genuine Unix underneath, is a large part of why macOS became so popular with developers.
4. Why the differences still bite
The fundamentals are universal. The specifics are not, and the specifics are what break programs that move from a laptop to a server. The photo-upload service, written on Windows and Mac laptops and deployed to Linux, can be bitten by every one of these:
- Path separators. A path built by hand as
"uploads\\" + nameworks on Windows and fails on Linux. Usepath.join, which picks the right separator. - Upper and lower case. NTFS and APFS normally treat
Photo.tsandphoto.tsas the same name; Linux does not (2.6.3). An import with the wrong case works locally and fails on the server. - Line endings. A shell script saved on Windows with
\r\nline endings fails on Linux with a baffling error such as/bin/bash^M: bad interpreter, because the\rbecomes part of the program name on the shebang line (2.8.1). Git can convert line endings automatically, and a.gitattributesfile makes the rule explicit. - Signals. Graceful shutdown on
SIGTERMcannot be tested by sending real signals on Windows. - Permissions. Unix
rwxbits and the executable bit do not exist on NTFS in the same form, so a script that runs on Linux may not be marked executable in the repository. - Resource limits. A laptop has no container memory limit, so a memory-hungry code path works locally and is killed in production (2.5.3).
The reliable fix is to develop inside the same Linux environment you deploy to, for example in a container through WSL 2 or a development container, so the kernel, the file system rules and the limits are the same everywhere (14.2.6).
What the interviewer will push on
"How do the Windows and macOS kernels relate to the Unix model?" They are checking that you know the families. Windows uses the NT hybrid kernel, unrelated to Unix but with the same core ideas: processes, threads, virtual memory, a system-call boundary. macOS uses XNU, a hybrid of the Mach microkernel and a BSD Unix layer, and is a certified Unix. The tell is mapping vocabulary: a handle is a file descriptor, the page file is swap, the working set is RSS.
"What is the difference between WSL 1 and WSL 2?" WSL 1 translated Linux system calls into NT kernel operations, with no Linux kernel. WSL 2 runs a real Linux kernel in a lightweight virtual machine, which is why everything, including Docker, works on it. Many candidates know only one of these.
"How does Windows create a process, given it has no fork?" CreateProcess names the program and passes options such as inherited handles and standard streams in one call. The strong answer adds why Unix split creation in two, and what that gap gave it.
"Why does code that works on my Mac fail on a Linux server?" Case sensitivity, path separators, line endings, missing signals or permissions, and container limits. Naming the ^M: bad interpreter error shows experience.
"Does Windows have signals?" Not Unix signals. It has console control events, window messages and TerminateProcess. Node maps Ctrl+C to SIGINT, but a real SIGTERM cannot be delivered to a Node process on Windows.
Something to volunteer that nobody asks for: NT's designer, Dave Cutler, previously designed VMS, and the resemblance is deliberate. Knowing that Windows and macOS are both hybrids, built from different ancestors, shows you see operating systems as a family of design choices rather than as brands.
Recall
- Modern Windows runs the Windows NT kernel (1993, led by Dave Cutler), not DOS. It is a hybrid kernel. The Executive (object, process, memory, I/O and security managers), a small kernel, drivers and the HAL all run in kernel mode.
ntdll.dllwraps the system calls. - A handle is NT's version of a file descriptor, but can name any object. Environment subsystems gave NT several personalities; WSL 1 translated Linux calls, WSL 2 runs a real Linux kernel in a lightweight VM.
- Windows has no
fork(CreateProcessdoes it in one step), no Unix signals (control events, messages,TerminateProcess), a page file for swap, the working set for RSS, and I/O completion ports for completion-based I/O. - macOS runs Darwin with the XNU kernel: Mach plus a BSD Unix layer plus I/O Kit, a certified Unix, with
launchdas PID 1,kqueueinstead ofepoll, no/proc, APFS, and ARM processors since 2020. - Laptop-to-Linux bugs come from path separators, case sensitivity,
\r\nline endings, missing signals and permissions, and absent limits; develop in the same Linux environment you deploy to.
Self-test: What does Windows_NT in the demo's output tell you? Name three Executive managers and the Part 2 chapter each corresponds to. Why does Docker need WSL 2 rather than WSL 1? Which parts of Part 2 work unchanged on a Mac, and which do not? Why does a script saved with Windows line endings fail with ^M: bad interpreter?
Quiz Bank
FoundationalHow do the Windows and macOS kernels relate to the Unix model taught in this Part?
Windows runs the Windows NT hybrid kernel: a layered design with an Executive of managers for processes, memory, I/O, objects and security, running in kernel mode. It is not Unix, but it has the same fundamentals: processes and threads, virtual memory with paging, a system-call boundary and file systems. They just have different names, such as a handle for a file descriptor and the page file for swap. macOS runs Darwin with the XNU kernel, a hybrid of the Mach microkernel and a BSD Unix layer, which makes it a certified Unix with real fork, exec, signals and a Unix shell.
FoundationalWhat is a Windows handle?
A handle is a small number a Windows process receives when it opens or creates a kernel object, and it indexes that process's table of open objects, just as a Unix file descriptor does. Unlike a descriptor, it can stand for many kinds of object: files, processes, threads, locks, events and registry keys, all managed by NT's object manager. Leaked handles accumulate like leaked descriptors, and Task Manager can show each process's handle count.
AppliedWhat is the difference between WSL 1 and WSL 2?
WSL 1 caught the system calls of Linux programs in a Windows driver and translated them into NT kernel operations; there was no Linux kernel. It was lightweight but some Linux features never worked properly and file access was slow. WSL 2 runs a genuine Linux kernel inside a small, fast-starting virtual machine on Windows's built-in hypervisor, so Linux programs get full compatibility, including the namespaces and cgroups that containers need. That is why Docker Desktop on Windows uses WSL 2.
InterviewWindows has no fork. How does it create processes, and what does that change?
Windows creates a process with CreateProcess. It names the program file to run, and takes a large set of options in one call: the command line, the environment, which handles the child inherits, where its standard streams go, and its priority. On Unix those settings are made by the child itself in the gap between fork and exec. The consequence is that features built on fork-without-exec, such as copy-on-write snapshots of a running process, have no direct equivalent on Windows, and tools that rely on fork, like some Python multiprocessing modes, must use a different method there.
InterviewCode works on a developer's Mac and Windows laptops but fails on the Linux server. List the operating-system differences that commonly cause this.
- Case sensitivity: APFS and NTFS normally ignore case; Linux does not, so imports with the wrong case fail.
- Paths: hand-built paths with
\fail on Linux; usepath.join. - Line endings: Windows
\r\nbreaks shell scripts on Linux, often as^M: bad interpreter. - Signals: graceful shutdown on
SIGTERMcannot be exercised with real signals on Windows. - Permissions: the executable bit and
rwxbehave differently, so scripts may not be executable. - Limits: containers impose memory and CPU limits that laptops do not.
The robust fix is developing and running tests inside the same Linux image that is deployed.
StaffYour team must support the photo-upload service's command-line tools on Windows, macOS and Linux. Which operating-system differences would you design around from the start?
Design around the differences that change behaviour, not just names:
- Process creation and shutdown: use the runtime's process APIs rather than shell strings; handle
SIGINTeverywhere,SIGTERMon Unix, and Windows console events; never rely onfork. - Files: build paths with the path library, normalise line endings in the repository, treat names as case-sensitive even on systems that are not, and do not depend on Unix permission bits on Windows.
- Environment: read configuration through the environment and files with platform-correct separators, and do not assume a shell is present or which one it is.
- I/O and limits: rely on the runtime's event loop, which uses
epoll,kqueueor completion ports underneath, rather than platform-specific calls.
Then run the test suite on all three systems in continuous integration, because the differences that matter are exactly the ones nobody remembers.
Scenario Drill
DrillA deploy script written on a Windows laptop fails on the Linux build server with '/usr/bin/env: bash\r: No such file or directory'. Using this page, explain and fix it.
The script was saved with Windows line endings, \r\n. On Linux, the kernel reads the shebang line (2.8.1) up to the \n, so the program name it receives is bash\r, with an invisible carriage return on the end. No program called bash\r exists, hence the error, which some systems print as ^M.
Fix the file by converting its line endings to \n, for example with an editor setting or the dos2unix tool. Fix the cause by telling Git how to store such files: a .gitattributes file with a rule such as *.sh text eol=lf makes Git always check shell scripts out with Linux line endings, on every developer's machine. Adding a check in continuous integration that rejects \r in scripts stops it coming back.
Next: two Windows features that every user meets, but few understand, are next: why Ctrl+Alt+Del always works, even when everything else is frozen, and the deep difference between Windows's two command lines. Page 2.9.2 explains both.