Terry Davis' TempleOS Brutal Take Down of Linus Torvalds

Terry Davis' TempleOS Brutal Take Down of Linus Torvalds — Terry Davis Old Archive

Terry Davis Old Archive

AI-assisted summary of Terry Davis' TempleOS Brutal Take Down of Linus Torvalds — original source. Check the original for full context.

Source published:

Key ideas

  • Terry Davis contrasts Linux and TempleOS using a vehicle metaphor: Linux is an over-engineered 20-gear semi-truck trapped in 1970s mainframe paradigms, while TempleOS is a lightweight motorcycle built for the raw, unprotected simplicity of a modern Commodore 64. (0:00)
  • TempleOS establishes a strict hard cap of 100,000 lines of code with zero third-party dependencies, allowing the entire operating system (~50,000 lines across kernel and compiler) to recompile from source in roughly one second without linkers or makefiles. (4:59)
  • By executing entirely in Ring 0 with identity-mapped memory and capping executable code to the lowest 2 GB, TempleOS performs 4 to 4.5 million task context switches per second and uses compact 5-byte relative 32-bit call instructions. (12:17)
  • Davis rejects modern time-sharing and complex multi-tasking schedulers, designing TempleOS around a deterministic master-slave multi-core model explicitly tailored to push maximum CPU graphics and execution throughput for a single application at a time. (15:25)

Detailed notes

## Background This video was published on YouTube by the Terry Davis Old Archive channel on July 19, 2017. According to the description, the channel archives old videos created by Terry A. Davis before he deleted his original channel, crediting Vincent Canfield for preserving the footage. The page also provides links to other automated archive mirrors, Terry's official website, and a Vice Motherboard article covering his life as a programmer.

## TL;DR In this technical monologue, Terry Davis critiques modern operating systems, contrasting the design philosophy of Linux with his own creation, TempleOS. Davis argues that modern operating systems are weighed down by decades-old mainframe concepts such as complex file permissions, memory swapping, and sprawling multi-million-line codebases. Drawing an analogy between Linux as an unwieldy semi-truck and TempleOS as an uninhibited motorcycle, he champions a radical return to single-user Commodore 64 simplicity through identity-mapped Ring-0 execution, deterministic multi-core processing, and a strict 100,000-line code cap. He defends idiosyncratic engineering choices like a 2 GB code memory limit to optimize x86-64 instructions and demonstrates that stripped-down architecture delivers millions of context switches per second without academic abstraction.

## Atmosphere & style The presentation carries the unmistakable intensity of a lone digital artisan delivering an unscripted, defensive manifesto from his desktop. Davis speaks with raw, combative conviction, fluidly alternating between granular architectural breakdowns and barbed attacks against mainstream software culture. The mood feels intimate, erratic, and deeply defiant, pulling the viewer straight into the mind of an isolated genius determined to prove that simplicity outshines the entire computing establishment.

## Bulletin - [00:00](https://www.youtube.com/watch?v=gBE6glZNJuU&t=0s) Terry Davis contrasts Linux and TempleOS using a vehicle metaphor: Linux is an over-engineered 20-gear semi-truck trapped in 1970s mainframe paradigms, while TempleOS is a lightweight motorcycle built for the raw, unprotected simplicity of a modern Commodore 64. - [04:59](https://www.youtube.com/watch?v=gBE6glZNJuU&t=299s) TempleOS establishes a strict hard cap of 100,000 lines of code with zero third-party dependencies, allowing the entire operating system (~50,000 lines across kernel and compiler) to recompile from source in roughly one second without linkers or makefiles. - [12:17](https://www.youtube.com/watch?v=gBE6glZNJuU&t=737s) By executing entirely in Ring 0 with identity-mapped memory and capping executable code to the lowest 2 GB, TempleOS performs 4 to 4.5 million task context switches per second and uses compact 5-byte relative 32-bit call instructions. - [15:25](https://www.youtube.com/watch?v=gBE6glZNJuU&t=925s) Davis rejects modern time-sharing and complex multi-tasking schedulers, designing TempleOS around a deterministic master-slave multi-core model explicitly tailored to push maximum CPU graphics and execution throughput for a single application at a time.

## Key takeaways - [00:00](https://www.youtube.com/watch?v=gBE6glZNJuU&t=0s) Linux remains conceptually constrained by 1970s mainframe requirements, such as managing 2 MB of RAM across 100 simultaneous users with strict multi-user permissions and crash prevention. - [00:00](https://www.youtube.com/watch?v=gBE6glZNJuU&t=0s) The design goal of TempleOS is to recapture the spirit of the Commodore 64, treating the user as an active programmer-developer with direct hardware and graphics access. - [02:44](https://www.youtube.com/watch?v=gBE6glZNJuU&t=164s) Modern computing has abundant gigabytes of RAM, rendering disk swapping and virtual memory thrashing an unacceptable failure rather than a useful conservation technique. - [02:44](https://www.youtube.com/watch?v=gBE6glZNJuU&t=164s) TempleOS loads entire files directly into memory instead of relying on legacy UNIX-style pipeline streaming and buffer chunks. - [04:59](https://www.youtube.com/watch?v=gBE6glZNJuU&t=299s) Scaling downward yields non-linear architectural benefits, eliminating the need for linkers, make utilities, and separate header declarations in favor of chained `#include` files. - [08:56](https://www.youtube.com/watch?v=gBE6glZNJuU&t=536s) Restricting code memory to the lowest 2 GB is an intentional x86-64 optimization that allows 5-byte `CALL REL32` instructions rather than bloated 13-byte indirect absolute calls. - [12:17](https://www.youtube.com/watch?v=gBE6glZNJuU&t=737s) Operating entirely in Ring 0 with an identity-mapped address space avoids memory map swaps and privilege transitions, enabling 4 to 4.5 million context switches per second. - [12:17](https://www.youtube.com/watch?v=gBE6glZNJuU&t=737s) Task switching in TempleOS is measurably faster than reading a single hardware I/O port, which takes roughly one microsecond via x86 `IN` and `OUT` instructions. - [15:25](https://www.youtube.com/watch?v=gBE6glZNJuU&t=925s) Davis rejects multi-user multitasking trade-offs, prioritizing running a single multi-threaded application at peak performance over juggling multiple competing consumer games. - [17:47](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1067s) TempleOS eliminates the distinction between processes and threads, treating all execution units as tasks within a shared memory map managed by a lightweight round-robin scheduler. - [17:47](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1067s) Academic computer science is criticized for admiring and producing artificial complexity in journals to project prestige rather than pursuing elegant simplicity. - [21:53](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1313s) TempleOS implements a deterministic master-slave SMP architecture, running primary logic on Core 0 and explicitly dispatching parallel workloads across secondary cores to avoid dynamic scheduler frame drops. - [21:53](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1313s) Unlike Linux and mainstream OSes that offload graphics to the GPU, TempleOS renders multi-threaded real-time graphics directly on the CPU across all eight cores. - [24:19](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1459s) A compact 100,000-line codebase functions cleanly with a single global symbol table, concise variable naming, and global variables, avoiding deep hierarchical namespace abstractions. - [24:19](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1459s) Modern programming curricula are faulted for insulating students from raw memory management, assembly code, and pointers instead of teaching low-level fundamentals like `malloc` and `free`.

## Detailed walkthrough ### [00:00](https://www.youtube.com/watch?v=gBE6glZNJuU&t=0s) Mainframe vs. Commodore 64: Vehicles of Computing

Terry Davis opens with a spontaneous lecture contrasting the core design philosophies of Linux and TempleOS. In his view, Linux is structurally trapped in the paradigm of a 1970s mainframe, an architecture designed around extreme resource scarcity—such as two megabytes of RAM shared across a hundred simultaneous users—where system crashes were completely intolerable and had to be avoided at all costs. In stark contrast, Davis explains that his operating system aspires to recreate the spirit of the Commodore 64, an intimate personal machine whose user manual directly taught hobbyists how to construct sprite graphics out of raw binary data and write quick BASIC programs.

```mermaid flowchart TD accTitle: Operating System Vehicle Analogies accDescr: Metaphorical comparison of Linux as a semi truck, Windows as a car, and TempleOS as a motorcycle. subgraph Analogy["Vehicle Analogies"] L["Linux: The Semi-Truck<br/>(20 gears, file permissions, multi-user overhead)"] W["Windows: The Passenger Car<br/>(Standard consumer product)"] T["TempleOS: The Motorcycle<br/>(Raw speed, no side airbags, crashes if you lean over)"] end ```

To illustrate this gulf in thinking, Davis deploys his signature vehicular metaphor: Linux is an industrial semi-truck, Windows is an everyday passenger car, and TempleOS is a lightweight motorcycle. A semi-truck has twenty gears and will never serve well as a passenger vehicle, just as elaborate multi-user file permissions have no business being forced into a consumer product. While Linux users remain deluded by enterprise complexity, Davis embraces the directness and inherent danger of a motorcycle, pointing out that an operating system stripped of safeguards does not bother with protective padding. As Terry Davis puts it: “Linux is the semi, Windows is a car, TempleOS is a motorcycle.” He accepts that a user can easily crash TempleOS if they make a mistake, remarking that if you lean over too far on a motorcycle it wipes out, so the straightforward remedy is simply not to do that.

- **Mainframe roots**: 1970s mainframes managed roughly 2 MB of RAM across 100 users, requiring absolute crash prevention. - **Commodore 64 heritage**: Designed for single-user creativity, sprite manipulation using binary numbers, and simple BASIC scripting. - **The vehicle metaphor**: Linux represents a 20-gear semi-truck burdened by file permissions; Windows is a passenger car; TempleOS is a bare-bones motorcycle without safety nets.

---

[02:44](https://www.youtube.com/watch?v=gBE6glZNJuU&t=164s) Fighting the Last War: Memory, Swapping, and File Loading

Davis argues that mainstream software engineers constantly handicap themselves because they are endlessly “fighting the last war” by blindly copying mainframe concepts from forty years ago. When a computer only possessed two megabytes of RAM for a hundred users, virtual memory and disk paging were absolute necessities. On modern workstations equipped with gigabytes of memory, however, paging code out to disk is so prohibitively slow that any user whose system begins thrashing immediately considers it an unacceptable failure. Davis clarifies that while he is not attacking hardware memory paging itself, traditional virtual memory swapping simply has no place on modern personal computers.

This divergent philosophy fundamentally changes how TempleOS approaches I/O and resource consumption. In a mainframe or Linux environment, a compiler must walk on eggshells to avoid hogging memory, relying on UNIX pipelines that stream tiny chunks of data sequentially through buffers. Because modern machines have abundant RAM, Davis rejects chunk-based streaming in favor of reading entire files into memory all at once, maximizing simplicity and aesthetics. As Terry Davis notes: “If you ever do cause it to start swapping to disk, it's way too slow to be acceptable.” For him, clean, beautiful source code takes precedence over backward-looking conservation mechanisms.

---

[04:59](https://www.youtube.com/watch?v=gBE6glZNJuU&t=299s) Scaling Down: The User-Developer and 100,000 Lines of Code

Davis asserts that his highest ideal is minimizing lines of code (LOC), establishing a hard limit of 100,000 lines for the entire TempleOS codebase and completely outlawing third-party libraries. His operating system is tailored strictly for the “user-developer”—a term he considers trademarking—emulating the Commodore 64 era where the computer booted into a 20 KB ROM and the person sitting at the keyboard was simultaneously the operator and the programmer. Rather than catering to enterprise software vendors, Davis prefers to cut out third-party developers entirely to protect the purity of the user-developer experience.

Modern software developers, Davis argues, have been thoroughly “Jedi mind-tricked” by an obsession with scaling up to massive proportions. He points out that scaling is a two-way street, and scaling downward produces non-linear benefits that dramatically simplify an operating system. Because TempleOS scales down, it eliminates the need for linkers, make utilities, and header separation. An entire project is defined simply by chaining code files together with `#include` statements. Demonstrating live on his screen, Davis taps a single shortcut key to execute a full system recompile from scratch:

```mermaid flowchart LR accTitle: TempleOS Compilation Architecture accDescr: Shows the compilation pipeline from source files directly to binary execution without linkers. subgraph Build["TempleOS Streamlined Build"] direction LR Src["Code Files<br/>(#include source directly)"] --> K["Kernel<br/>(~20,000 LOC)"] Src --> C["Compiler<br/>(~20,000 LOC)"] K & C --> JIT["Total ~50,000 LOC<br/>Compiles in ~1 Second"] JIT --> Boot["Adam Directory<br/>Compiled at Boot / JIT"] end ```

As Terry Davis emphasizes regarding the industry's architectural blind spot: “Guess what, scaling works both ways: you can get bigger, what happens if you look the other direction and you scale down?” In roughly one second, TempleOS recompiles roughly 50,000 lines of code—consisting of a 20,000-line kernel and a 20,000-line compiler—with the remainder handled via just-in-time compilation, starting with the root "Adam" task named after Adam and Eve.

- **Code limit**: Strict cap of 100,000 lines of code for the entire operating system, with zero third-party dependencies. - **User-developer model**: Direct lineage from the Commodore 64's all-in-one ROM environment. - **Build system simplicity**: No linker, no `make` utility; code files directly `#include` other implementation files. - **Compilation speed**: Compiles ~50,000 lines of code (20,000 kernel + 20,000 compiler) in approximately one second flat.

---

[08:56](https://www.youtube.com/watch?v=gBE6glZNJuU&t=536s) The 2GB Limit, x86-64 CALL Instructions, and Arrogant Engineers

Davis addresses the frequent criticism he receives for imposing a 2 GB code memory limit on a 64-bit operating system. Programmers conditioned by corporate computing scoff at this ceiling, reflexively mocking Bill Gates' apocryphal claim that 640 KB of memory should be enough for anyone and insisting that memory caps are always foolish. Davis fires back that people who cannot define "what is enough" are mere sheep rather than shepherds, pointing out that Linux itself is an unoriginal rehash of UNIX. He compares modern arrogant engineers to a hypothetical Westinghouse electrical engineer in 1900 mocking Nikola Tesla, or two thousand anonymous physicists at CERN walking around with unearned superiority without ever pioneering an original breakthrough of their own.

Technically, the 2 GB code limit is an intentional optimization for binary size and execution speed. In x86-64 architecture, there is no direct 64-bit relative `CALL` instruction. Calling an arbitrary 64-bit absolute address requires loading the destination into a register and executing an indirect call, which bloats the instruction footprint:

| Call Strategy | Assembly Sequence | Total Size | |:--- |:--- |:--- | | **TempleOS (Lowest 2 GB)** | `CALL REL32` | **5 bytes** | | **Standard 64-bit Far Call** | `MOV RAX, imm64` (10 bytes) + `CALL RAX` (3 bytes) | **13 bytes** |

By restricting all executable code to the lowest two gigabytes of the address space, TempleOS can exclusively use the compact 5-byte relative 32-bit call instruction (`CALL REL32`), resulting in tighter cache utilization and faster performance. As Terry Davis remarks about conventional programmers' knee-jerk mockery: “So when I say 2 gig, they say, 'We're not that stupid, we know it's never enough.'”

---

[12:17](https://www.youtube.com/watch?v=gBE6glZNJuU&t=737s) Port I/O, Instant Context Switches, and Ring-0 Simplicity

To demonstrate the raw efficiency of his architecture, Davis walks through a low-level hardware driver loop waiting for a disk controller to become ready. The driver executes an `IN` instruction against an I/O status port and checks the busy flag:

``` // TempleOS hardware polling pattern if (status & BUSY) Yield(); ```

Davis explains the performance math: an x86 `IN` or `OUT` instruction takes approximately one microsecond (translating to a baseline ceiling of roughly one million operations per second). In Linux, relinquishing execution via a task yield incurs massive overhead because the kernel must switch privilege levels, reload register state, and swap page tables by reloading the `CR3` register. TempleOS, however, runs entirely in Ring 0 with an identity-mapped address space: tasks never alter memory mappings or transition privilege rings.

```mermaid flowchart TD accTitle: Context Switch Overhead Comparison accDescr: Contrasts heavy Linux context switches against the lightweight identity-mapped TempleOS yield. subgraph LinuxSwitch["Linux Context Switch (High Overhead)"] L1["Change Privilege Level"] --> L2["Reload CR3 (Change Memory Map)"] L2 --> L3["Save/Restore Extensive Task State"] end subgraph TempleOSSwitch["TempleOS Context Switch (Ring-0 Identity-Mapped)"] T1["No Memory Map Change (Identity Mapped)"] --> T2["No Privilege Transition (Always Ring 0)"] T2 --> T3["Fast Register Swap (~4-4.5M Switches/Sec)"] end ```

Davis claims that TempleOS can perform between 4 and 4.5 million task context switches per second, meaning switching tasks in software is actually faster than reading a single hardware I/O port. As Terry Davis states: “I can save tasks and switch tasks faster than I can read a port.” To prove his assertion, he runs a live benchmark on his screen containing an unconstrained `while (TRUE) Yield();` loop, observing task switch counters soar into the millions even while background video capture is active.

- **Port I/O baseline**: Hardware `IN`/`OUT` instructions take roughly 1 µs (~1,000,000 ops/sec). - **Linux context penalty**: Mandates privilege boundary crossings, `CR3` page table reloading, and full memory map switches. - **TempleOS speed**: Identity mapping and permanent Ring-0 execution allow between 4,000,000 and 4,500,000 task switches per second.

---

[15:25](https://www.youtube.com/watch?v=gBE6glZNJuU&t=925s) SMP Architecture, Trivial Solutions, and Single-App Mastery

Davis critiques the multi-user, multi-tasking priorities of modern operating systems, arguing that Linux developers “would move heaven and earth just so that you can play two video games at once.” He compares this engineering over-complication to the famous fable of NASA spending millions to invent a space pen while Soviet cosmonauts simply used a pencil. While acknowledging the pencil story is technically a myth, he points out that it embodies the design philosophy behind his company, which he intentionally named *Trivial Solutions*. By dropping CPU privilege rings and complex task isolations, TempleOS embraces straightforward solutions over over-engineered safety nets.

Davis then diagrams the symmetric multiprocessing (SMP) model in TempleOS across his eight CPU cores. The system hierarchy begins with the master "Adam" task, which spawns executive set-tasks for each core. On Core 0, the machine runs the Window Manager (responsible for painting screen frames), the frame grabber, the active user task, and Adam itself. The design does not attempt to juggle dozens of competing consumer applications; instead, it is explicitly built to dedicate the machine to a single primary application at a time—such as an intensive multi-threaded game—mirroring how enthusiasts pushed the Commodore 64 to its absolute limits. As Terry Davis summarizes his operating philosophy: “Basically, you're going to run one application at a time, and it might be multi-threaded on this.”

[17:47](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1067s) Simplicity in Task Scheduling and the Rejection of Overcomplicated Mainframes

Terry Davis explains that in TempleOS, everything operates within the exact same memory map, eliminating any distinction between processes and threads—they are simply tasks. When a task waits for disk access, it performs a simple yield. Terry expresses frustration with conventional computer science theory, dismissing critics who label this approach blocking as “little brainwashed book people” and comparing his situation to Nikola Tesla being ridiculed by uninspired academics. He asserts that modern operating systems are stuck fighting the last war by building 1970s-style mainframes, whereas he is adapting to a completely modern computing reality.

```mermaid flowchart TD accTitle: TempleOS Task Scheduling Loop accDescr: Round-robin scheduler evaluating tasks based on wait states.

subgraph Scheduler ["Round-Robin Task Ring"] T1["Task 1 (Running)"] T2["Task 2 (Waiting for Disk)"] T3["Task 3 (Waiting on Message/Time)"] end

T1 -->|"Yields CPU"| T2 T2 -->|"Swap in, check ready, swap out (~0.25 µs)"| T3 T3 -->|"Permanently skipped until event triggers"| T1 ```

Terry deliberately uses a basic round-robin scheduler without task priorities. He argues that complicating code just to impress others is an academic sickness, stating: “Is it because I can't do priorities? No, it's because an idiot admires complexity, a genius admires simplicity, a physicist tries to make it simple anyway.” He adds that people in academic journals write deliberately convoluted material so that others treat them like gods because no one can understand it.

- Tasks waiting for a message or a timer tick (jiffy) are swapped out permanently until the event arrives. - When waiting for input or disk reads, the scheduler cycles through tasks; a context check costs roughly a quarter of a microsecond. - For five tasks, cycling takes about one microsecond, whereas on an operating system with a hundred tasks, this model would become problematic. - Terry clarifies that high-concurrency time-sharing is irrelevant to his architecture: “I'm making a Commodore 64; I don't do sharing.” - The operating system is explicitly architected around a single video game running across multiple threads, rather than trying to juggle multiple heavy desktop games simultaneously.

---

[21:53](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1313s) Multi-Core Architecture: Master-Slave vs. Linux

Addressing symmetric multiprocessing (SMP), Terry responds to Linus Torvalds’ remark that multi-core processors are overrated. TempleOS implements a strict master-slave paradigm: all primary application logic executes on Core 0, and whenever the application requires parallel computing power, it explicitly spawns slave tasks directly onto specific secondary cores.

Terry highlights his flight simulator demo running across all eight CPU cores to show why Linux’s scheduling model fails real-time graphics. Linus Torvalds offloads parallel graphics processing entirely to the GPU, leaving the CPU largely idle on a single core. In contrast, TempleOS computes graphics purely on the CPU. Under a conventional dynamic scheduler, assigning seven graphics tasks across cores risks clumping two tasks onto a single core, cutting frame rates in half from 30 frames per second down to 15 frames per second. Because TempleOS allows deterministic direct core targeting, Terry insists it utilizes multi-core far more effectively for dedicated single applications.

> “TempleOS can only run one application faster; Linux can run two applications faster—their geniuses, okay.”

---

[24:19](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1459s) Scaling Down: Single Namespaces, Short Variables, and Low-Level Mastery

Terry shifts to codebase size and software ergonomics, arguing that systems do not merely degrade when scaled up—they actually become significantly better when scaled down. While enterprise systems require deep hierarchies, packages, and namespaces to manage code bloat, a compact operating system needs only a single, flat global symbol table. Terry inspects his own symbol table in the editor to illustrate this elegance, contrasting TempleOS’s 100,000-line codebase against the tens of millions of lines comprising Linux, which he accuses Linus of bloating purely to intimidate others.

```mermaid flowchart LR accTitle: Architectural Scale Comparison accDescr: Contrasting TempleOS's compact model with conventional multi-million line kernels.

subgraph ScaledDown ["TempleOS Philosophy"] A["100,000 Lines of Code"] --> B["Single Namespace"] B --> C["Short Variable Names & Globals"] C --> D["Direct Hardware / CPU Control"] end

subgraph Bloated ["Modern OS Philosophy"] E["20–50 Million Lines of Code"] --> F["Complex Hierarchical Namespaces"] F --> G["Overly Verbose Variable Names"] G --> H["Abstracted Runtimes & Safety Nets"] end ```

He rejects modern dogmas that forbid global variables and short identifier names. In small programs—such as a 180-line game a kid might write—global variables and concise names are the correct, natural approach. Terry lambasts modern pedagogical trends and high-level language abstractions that insulate students from memory mechanics:

> “Nobody knows what a pointer is, nobody knows what assembly code is, they've all been so confused by the liberals trying to make it easy for them.”

- Terry demands that programmers “just man up and learn what `malloc` and `free` are” rather than relying on safety wrappers that conceal hardware reality. - While he shares Linus Torvalds’ preference for raw systems programming over heavy academic abstractions, Terry notes he prefers C++ extensions (as in his dialect, HolyC) while retaining raw C simplicity. - He notes an industry-versus-academia cultural rift: academia publishes discoveries to seek prestige, whereas private industry hoards breakthroughs as trade secrets. - Terry champions concise naming conventions across his APIs—such as compact 64-bit datetime types—concluding that short, direct names make an operating system easy to navigate and completely understandable in the spirit of the Commodore 64.

## Notable quotes > [00:00](https://www.youtube.com/watch?v=gBE6glZNJuU&t=0s) Linux is the semi, Windows is a car, TempleOS is a motorcycle. — Terry Davis

> [17:47](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1067s) I'm making a Commodore 64; I don't do sharing. — Terry Davis

> [12:17](https://www.youtube.com/watch?v=gBE6glZNJuU&t=737s) I can save tasks and switch tasks faster than I can read a port. — Terry Davis

> [24:19](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1459s) Nobody knows what a pointer is, nobody knows what assembly code is, they've all been so confused by the liberals trying to make it easy for them. — Terry Davis

## Mentioned Terry Davis, Linus Torvalds, TempleOS, Linux, Windows, Commodore 64, UNIX, Bill Gates, Nikola Tesla, Westinghouse, CERN, NASA, Trivial Solutions, HolyC, Vincent Canfield

## Video description This is an archive channel dedicated to hosting all of Terry A. Davis' old videos before he deleted his channel.

Full credit for saving these goes to Vincent Canfield https://vc.gg/templeos/

I just upload them to YouTube.

Other archive channels that upload from his website:

https://www.youtube.com/channel/UC7XZSFX4YhqzXbt513F2sEA (this one is fully automated)

https://www.youtube.com/channel/UC2JvKvUmoWdtE55ta15a3tg

https://www.youtube.com/channel/UCEPEqMr199q3iRTwToIotVA

Vice article on Terry A Davis: https://motherboard.vice.com/en_us/article/wnj43x/gods-lonely-programmer

Terry's official website: http://www.templeos.org/

[Source](https://www.youtube.com/watch?v=gBE6glZNJuU)

中文简报

特里·戴维斯借TempleOS犀利抨击林纳斯·托瓦兹 在这段技术独白中,特里·戴维斯批评了现代操作系统,并将Linux的设计哲学与他自己创造的TempleOS进行了对比。戴维斯认为,现代操作系统受困于数十年前的大型机概念,例如复杂的文件权限、内存交换以及庞大臃肿的数百万行代码库。他将Linux比作笨重的半挂卡车,而将TempleOS比作无拘无束的摩托车,主张通过等同映射的Ring-0执行、确定性多核处理以及严格的10万行代码上限,彻底重返Commodore 64单用户时代的极简主义。他为诸如限制2 GB代码内存以优化x86-64指令等独特工程选择进行了辩护,并证明这种极致精简的架构无需学术抽象即可提供每秒数百万次的上下文切换。 特里·戴维斯用载具作比来对比Linux与TempleOS:Linux是困在1970年代大型机范式中、过度设计的20挡半挂卡车,而TempleOS则是专为现代Commodore 64纯粹、无保护的极简主义而打造的轻型摩托车。 (0:00) TempleOS确立了严格的10万行代码硬性上限且零第三方依赖,使整个操作系统(内核与编译器共约5万行代码)在无需链接器或makefile的情况下,约一秒内即可从源码重新编译。 (4:59) 通过完全在Ring 0中运行并采用等同映射内存,且将可执行代码限制在最低2 GB以内,TempleOS每秒可执行400万至450万次任务上下文切换,并使用紧凑的5字节相对32位调用指令。 (12:17) 戴维斯摒弃了现代分时系统与复杂的多任务调度器,围绕确定性的主从多核模型设计TempleOS,专门用于为单次运行的单个应用程序压榨出极致的CPU图形与执行吞吐量。 (15:25)

Detailed notes — zh

## Background 该视频由 YouTube 归档频道 Terry Davis Old Archive 于 2017 年 7 月 19 日发布。视频内容源自已被 Terry A. Davis 本人删除的原频道,由 Vincent Canfield 抢救并公开备份,记录了 Terry 对其独立开发的 TempleOS 架构哲学的阐述及其对现代操作系统的激烈批判。 ## TL;DR Terry Davis 深入剖析了 TempleOS 独特的极简系统设计哲学,并对 Linux 及现代操作系统的复杂架构展开了全方位抨击。他认为主流系统盲目继承 1970 年代大型机的多用户隔离思维,堆砌了虚拟内存交换、繁琐权限与深层特权级等冗杂包袱,而 TempleOS 则是面向现代硬件的 Commodore 64,旨在打造无保护层、全特权开放的单用户“摩托车”。通过将整机严格限制在 10 万行代码以内、锁定 2 GB 代码空间以启用 32 位相对跳转,以及全系统共享内存映射,TempleOS 实现了闪电般的系统重编译与微秒级的上下文切换。此外,Terry 还展示了其主从式对称多处理(SMP)架构如何凭借纯 CPU 软件渲染压榨全部核心性能,力证代码规模缩减带来的颠覆性收益,并呼吁重拾直面底层的纯粹黑客精神。 ## Atmosphere & style 整段视频充满了一种激烈、桀骜不驯且高度狂热的独白氛围。Terry Davis 展现出一种近乎先知般的自负与偏执,在飞速敲击键盘、现场重编译系统的利落操作中,夹杂着对学术界“书呆子”与主流软件工程师辛辣刻薄的嘲讽。观众能清晰感受到他在技术细节上的惊人洞察力与极度个人英雄主义的碰撞,整场演示既像是一场孤胆极客对整个现代软件工业的绝望宣战,又带有一种未经修饰、真实得令人屏息的悲剧美学色彩。 ## Bulletin - [00:00](https://www.youtube.com/watch?v=gBE6glZNJuU&t=0s) Terry Davis 批判 Linux 仍停留在 1970 年代大型机多用户资源争夺的旧思维中,而将 TempleOS 定位为现代版 Commodore 64:舍弃虚拟内存交换与文件权限等隔离机制,追求单用户对硬件的极致掌控与代码极简。 - [06:28](https://www.youtube.com/watch?v=gBE6glZNJuU&t=388s) TempleOS 将全部核心系统代码严格限制在 10 万行以内且无任何外部依赖,通过砍掉复杂链接器与构建流程,实现了单键 1 秒内完成 5 万行核心代码从零编译的全系统重构。 - [08:56](https://www.youtube.com/watch?v=gBE6glZNJuU&t=536s) 系统强制所有可执行代码驻留在内存最低 2 GB 空间,从而在 x86-64 架构下全程采用仅占 5 字节的 32 位相对寻址调用(CALL REL32),大幅降低指令体积并提升执行效率。 - [12:17](https://www.youtube.com/watch?v=gBE6glZNJuU&t=737s) 所有代码统一运行在 Ring 0 且共享全局内存映射,免去了页表刷新与特权级检查,使系统每秒可执行高达 400 万至 450 万次上下文切换,单次任务切换开销低至约 0.25 微秒。 - [21:53](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1313s) 在对称多处理(SMP)架构上,TempleOS 采用主从模式由 CPU 直接并行渲染图形,专为单个应用榨干所有多核性能设计,并抨击现代调度器的不可预测性会引发严重的帧率波动。 ## Key takeaways - [00:00](https://www.youtube.com/watch?v=gBE6glZNJuU&t=0s) 操作系统定位的比喻:Linux 是结构繁琐的多用户半挂式卡车,Windows 是妥协折中的轿车,而 TempleOS 是一辆剔除所有非必要保护与安全气囊、允许直接触碰底层的摩托车。 - [02:44](https://www.youtube.com/watch?v=gBE6glZNJuU&t=164s) 在当代数 GB 内存普及的背景下,虚拟内存向磁盘交换(swapping)已毫无现实意义,直接将完整文件全量载入内存能彻底避免堆砌丑陋复杂的管理代码。 - [02:44](https://www.youtube.com/watch?v=gBE6glZNJuU&t=164s) 代码行数最小化(Minimum Lines of Code)是核心设计准则,通过重塑“用户即开发者”模式,防止第三方依赖引发系统架构膨胀。 - [06:28](https://www.youtube.com/watch?v=gBE6glZNJuU&t=388s) 架构反向收缩(scale down)能够带来爆发式的性能与简捷性收益,TempleOS 无需链接器即可在 1 秒内完成全系统核心的快速编译,并在引导阶段完成剩余组件的 JIT 编译。 - [08:56](https://www.youtube.com/watch?v=gBE6glZNJuU&t=536s) 外界盲目崇拜无限可扩展性并嘲讽 2GB 代码限制,实则忽略了 x86-64 缺少原生 64 位绝对直接调用指令、间接调用会导致指令膨胀与流水线拖慢的底层架构现实。 - [12:17](https://www.youtube.com/watch?v=gBE6glZNJuU&t=737s) 由于不切换 CPU 特权级且不刷新 CR3 寄存器页表映射,TempleOS 切换任务的开销比执行一次硬件 I/O 端口输入指令(IN)更轻量。 - [12:17](https://www.youtube.com/watch?v=gBE6glZNJuU&t=737s) 多任务架构由根任务 Adam 派生各核专属执行任务,0 号核心专注处理窗口管理与系统服务,所有多核算力均服务于前台当前程序而非多用户隔离内耗。 - [17:47](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1067s) 系统内部取消进程、线程与任务的概念区分,采用无优先级的纯粹轮转调度(Round-Robin),杜绝学术界故意制造的高深复杂抽象。 - [21:53](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1313s) 针对 Linus Torvalds 所谓“多核被高估”的言论,Terry 认为 Linux 将渲染转嫁给独立 GPU 导致 CPU 闲置,而 TempleOS 则让多核 CPU 亲自进行纯软件图形渲染以实现单应用性能极致化。 - [24:19](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1459s) 系统规模受控在 10 万行代码后,全局变量和单一命名空间能让代码变得精简直接,无需引入复杂的命名空间和冗长的变量标识符。 - [24:19](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1459s) 现代计算机教育过度推崇高级抽象与过度保护,反而阻碍了开发者对指针、汇编及 malloc/free 等真实底层机制的理解。 - [24:19](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1459s) Terry 认同 Linus Torvalds 坚决排斥 C++ 的立场,但在自身系统中采用了轻量扩展的 C/C++ 语法与 64 位整数日期时间 API,力求让个人开发者能够完整理解并掌控整个系统。 ## Detailed walkthrough ### [00:00](https://www.youtube.com/watch?v=gBE6glZNJuU&t=0s) 操作系统哲学的碰撞:大型机、载重卡车与纯粹的摩托车 Terry Davis 围绕自旋锁(spinlocks)与系统设计哲学展开讨论。他指出,Linux 本质上是在试图重塑 1970 年代的大型机架构:当年硬件资源极其匮乏,一台机器仅有大约 2 MB 内存,却需要同时服务 100 名用户,任何系统崩溃都是灾难性的。相反,TempleOS 的定位是一台现代的 Commodore 64。在 Commodore 64 的用户手册里,官方教导用户如何使用二进制数据去手工绘制精灵图(sprite graphics),用户写着小巧的 BASIC 脚本,系统纯粹是为业余爱好者与创造者而生。 为了形象地概括主流操作系统的分歧,Terry 给出了一个汽车隐喻:“Linux 是半挂式卡车(Semi-truck),Windows 是轿车,而 TempleOS 是一辆摩托车。”卡车拥有 20 多个挡位,结构复杂笨重,注定无法成为面向普通乘客的家用工具;像文件权限系统(file permissions)这种繁琐的机制,根本不该存在于消费级产品中。在摩托车上,系统去掉了所有多余的保护层,就像摩托车根本没有侧面安全气囊一样。Terry 直言:“如果你在摩托车上倾角过大,它就会摔毁;这很疯狂吗?别那么做就是了。”在 TempleOS 中让系统崩溃十分容易,但这并非操作系统的缺陷,而是摩托车设计理念必然带来的纯粹与自由。 - **操作系统定位对比**: - **Linux(半挂卡车)**:继承 1970 年代大型机基因,为多用户、重型隔离、高复杂度和严格容错设计。 - **Windows(轿车)**:妥协折中的通用消费级产品。 - **TempleOS(摩托车)**:极致精简、无侧气囊保护、面向单用户且允许直接接触底层。 --- ### [02:44](https://www.youtube.com/watch?v=gBE6glZNJuU&t=164s) 内存误区与“用户兼开发者”理念 现代软件开发者陷入了僵化思维,总是“在打上一场战争”。当代计算机动辄配备数 GB 内存,但许多人依然保留着 100 人抢夺 2 MB 内存时的老旧习惯。在 Terry 看来,向磁盘进行虚拟内存交换(swapping to disk)在现代计算中早已过时:一旦系统触发磁盘交换,其极度缓慢的读写惩罚在现实中根本无法被接受。与其为了防止极端溢出而堆砌丑陋复杂的虚拟内存管理代码,不如彻底摒弃磁盘交换,追求干净优雅的代码。在数据吞吐上,Linux 因为内存受限历史,习惯使用管道(pipe)切碎数据一点点流式读取,而 TempleOS 则是直接将完整文件一次性读入内存。 Terry 确立的核心指标是代码行数最小化(Minimum Lines of Code)。在设计遇到冲突时,必须毫不犹豫地选择代码量更少的方案。他提出并强调了“用户即开发者”(user developer)概念:在 Commodore 64 时代,用户与开发者本为一体,不需要繁冗的中间层。为了彻底杜绝外部膨胀,Terry 甚至考虑禁止第三方开发者引入臃肿生态,并将整个 TempleOS 的内核与核心系统严格限制在 10 万行代码之内,且绝不依赖任何第三方库。 ```mermaid flowchart LR accTitle: TempleOS 与 Linux 资源架构与开发哲学对比 accDescr: 比较 Linux 继承的大型机模式与 TempleOS 追求的精简 Commodore 64 模式。 subgraph LinuxModel["Linux 架构理念 (大型机思维)"] direction TB L1["历史背景: 2MB 内存 / 100 用户"] --> L2["虚拟内存与磁盘交换 (Swapping)"] L2 --> L3["管道流式切片处理 (Pipes)"] L3 --> L4["沉重的权限体系与第三方依赖膨胀"] end subgraph TempleOSModel["TempleOS 架构理念 (Commodore 64 思维)"] direction TB T1["现代硬件: GB 级内存全掌控"] --> T2["抛弃磁盘交换,保持代码干净"] T2 --> T3["全文件直接载入 (Load Whole Files)"] T3 --> T4["内核与系统严格限制在 10 万行代码内"] end ``` - **核心原则与数据**: - 核心设计最高目标:最少代码行数(Lines of Code)。 - 代码总量上限设定:100,000 行代码(无任何外部第三方库)。 - 历史参照:Commodore 64 仅凭 20 KB ROM 即可自给自足,所有工具随系统一体化提供。 --- ### [06:28](https://www.youtube.com/watch?v=gBE6glZNJuU&t=388s) 规模收缩红利与单键闪电编译 软件行业充斥着对“可扩展性(Scaling)”的盲目崇拜,所有人都被灌输了单一的思维定势。Terry 指出,扩展性是双向的:当软件规模往上膨胀时,复杂度不是线性增加,而是呈现灾难性的非线性恶化;但当架构向相反方向收缩(scale down)时,系统的简捷性与性能也将迎来非线性的爆发式收益。 由于砍掉了所有不必要的结构,TempleOS 没有传统意义上的链接器(Linker),也没有复杂的 Make 构建体系。在开发时,系统直接在源文件中使用类似 `#include` 的方式连同代码本身一同组织,随后通过热键瞬间完成全系统构建。在录制现场,Terry 演示了全系统重建过程:他按下一个快捷键(Make All),在短短一秒之内,50,000 行核心代码(包括 20,000 行内核与 20,000 行编译器及相关基础组件)便完成了从零开始的全部重新编译。至于剩余组件,均由系统在引导启动时即时编译(JIT),例如在开机阶段直接编译以圣经人物命名的 `Adam` 根目录。 --- ### [08:56](https://www.youtube.com/watch?v=gBE6glZNJuU&t=536s) 2GB 代码空间限制与 64 位调用优化 在 64 位系统的地址分配上,Terry 设定了所有代码必须驻留在内存最低 2 GB 空间的硬性限制。这一决策引来了外界广泛的嘲弄,许多人搬出比尔·盖茨当年所谓的“640K 内存对每个人都足够了”来指责 Terry 缺乏远见。Terry 驳斥了这种盲从思潮:“当我说 2 GB 时,他们嘲笑说‘我们才没那么蠢,我们知道容量永远都不够’;这些人显然不是抽屉里最锋利的那把刀。” ``` 传统 64 位间接调用的汇编开销: MOV RAX, 0x123456789ABCDEF0; 占据约 10 字节 CALL RAX; 占据约 3 字节 总计:约 13 字节指令空间 TempleOS 的 32 位相对寻址调用: CALL REL32; 仅占 5 字节,执行更快 ``` Terry 解释了背后的底层架构原因:x86-64 架构并没有原生 64 位绝对寻址的直接跳转指令。如果要调用一个完全处于 64 位全空间任意位置的函数,CPU 必须先执行一条把 64 位目标地址载入寄存器的指令(耗费约 10 个字节),然后再通过寄存器完成间接跳转(`CALL RAX`,耗费 3 字节),不仅臃肿而且拖慢流水线速度。而将代码统一收敛在低 2 GB 空间后,系统可以全程使用仅占 5 字节的 32 位相对偏移调用指令(`CALL REL32`)。代码体积由此大幅缩减,缓存命中率与执行速度成倍提升。Terry 感叹行业中充斥着盲从的平庸之辈,如同 1900 年代西屋电气自诩懂数学、却对特斯拉冷嘲热讽的电气工程师,亦或是欧洲核子研究中心(CERN)里成百上千毫无开创性成果的物理学家,“当你只是在循着别人的足迹行走时,你根本不是一个开拓者(Trailblazer)”。 --- ### [12:17](https://www.youtube.com/watch?v=gBE6glZNJuU&t=737s) 上下文切换的极限性能与对称多处理架构 在微观性能剖析中,Terry 拿硬件驱动中的状态轮询作为典型场景:当驱动等待磁盘就绪时,通常会在循环中执行端口输入指令(`IN`),如果状态为忙碌(`BUSY`),则调用系统的让步函数(`Yield`)交出控制权。一条底层的 `IN` 或 `OUT` I/O 指令大约需要 1 微秒的时间;然而在 Linux 等现代操作系统中,任务上下文切换(Context Switch)的开销极其沉重——系统不仅必须切换特权级,触发权限检查并保存/恢复繁杂的状态寄存器,还必须刷新 `CR3` 寄存器以更换整套虚拟内存页表映射。 在 TempleOS 中,所有代码均运行在同一特权级(Ring 0),并且全系统共享同一套内存映射,任务切换根本不需要触动页表。这赋予了 TempleOS 惊人的任务调度速度:Terry 在终端运行死循环 `while(true) yield;` 进行压力测试,证明其系统每秒能够执行 400 万至 450 万次上下文保存与恢复。换言之,在 TempleOS 内部切换一次任务,比读取一次硬件 I/O 端口还要快得多。 面对外界对多任务安全机制的质疑,Terry 讥讽道,Linux 拥趸花费无数心血只是为了能同时运行两款游戏,这种傲慢恰如那个流传甚广的太空笔传说:“NASA 花费数百万美元研发太空笔,而俄罗斯直接用铅笔。”虽然这是个虚构的寓言,但 Terry 正是将自己的公司命名为“平凡解决方案(Trivial Solutions)”,代表着去掉特权层、追求直截了当的极简工程主义。 在多核对称处理(SMP)方面,Terry 介绍了 TempleOS 的任务拓扑: - 系统由最初的 `Adam` 任务作为父节点,向下为各个 CPU 核心(示例机器配备 8 核)派生出一个专属的核执行管理任务(Executive Task/Set Task)。 - 0 号核心(Core 0)负责全局核心服务,常驻运行窗口管理器(负责屏幕窗口绘制)、帧抓取器(Frame Grabber)以及 Adam 任务。 - 系统针对的核心场景始终是单用户运行单款大型程序或游戏(类似 Commodore 64),该程序可在后台分发多线程动画任务,将多核算力全部压榨在当前用户眼前的工作上,而非在多用户之间搞无谓的隔离与资源内耗。 > “在 Linux 上,任务切换有巨大的开销;他们每次切换任务都必须保存 CR3,必须更换整个内存映射。我不更换内存映射,我也不切换特权级别。”—— Terry Davis ### [17:47](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1067s) 极简的调度与内存设计:为什么复杂性是愚蠢的 Terry Davis 深入阐述了 TempleOS 在内存管理与任务调度上的哲学。在 TempleOS 中,所有东西都使用相同的内存映射(Memory Map),因此“进程”(Process)、“线程”(Thread)与“任务”(Task)之间完全没有区别。当一个任务在等待磁盘 I/O 时,它直接执行轮询让步(Yield)。针对主流程序员可能会批评这种做法是“阻塞”(Blocking)的言论,Terry 嗤之以鼻,认为这些人是被教科书洗脑的书呆子,就像当年嘲讽特斯拉的那些平庸之辈一样,只会打“上一场战争”,在现代计算机上复刻 1970 年代的大型机架构。 ```mermaid flowchart TD accTitle: TempleOS 任务轮询与挂起逻辑 accDescr: 展示 TempleOS 调度器中基于循环轮询以及事件挂起的工作流程 subgraph Sched["循环调度器 (Round-Robin)"] T["当前执行任务"] T -->|"检查就绪状态"| Check{"处于等待?"} Check -->|"等待按键/消息/计时"| Sleep["完全换出 (不分配时间片)"] Check -->|"等待磁盘 I/O"| Yield["主动 Yield 让步"] Yield -->|"耗时 ~0.25 微秒"| Next["切换至下一任务"] Next --> T end ``` 在调度策略上,TempleOS 采用了极其纯粹的轮转调度(Round-Robin),完全抛弃了任务优先级概念。Terry 坚称这不是因为他写不出优先级调度,而是出于一种崇尚简洁的设计美学。他讽刺学术期刊和主流系统开发者故意制造极其混乱复杂的抽象,只为了让人觉得高深莫测: > “An idiot admires complexity, a genius admires simplicity, a physicist tries to make it simple anyway.” —— Terry Davis - 在调度开销方面,Terry 计算出单次任务切换大约仅需四分之一微秒(0.25 µs),即使有 5 个任务在循环等待,整体轮换一圈也才耗费约 1 微秒。 - 任务若在等待按键、消息传递或特定的时钟节拍(Jiffy),会被彻底换出调度队列,直到条件满足才重新加载。 - 面对“如果系统有一百个任务该怎么办”的质疑,Terry 直言这不是他的设计目标,因为 TempleOS 的定位是一台现代版的准 Commodore 64,核心场景是单用户操作,而不是多用户分时共享。如果一个任务要读取 20MB 的磁盘数据,完全有权直接独占资源。 --- ### [21:53](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1313s) SMP 架构与多核之争:TempleOS 对决 Linux Terry 提到了 Linus Torvalds 近期发表的“多核被高估了”的言论,并以此展开对对称多处理(SMP)的激烈抨击。TempleOS 采用了一套极端纯粹的“主从模式”(Master-Slave)架构:所有常规应用程序默认运行在 CPU 核心 0(Core 0)上,只有当主程序需要并行加速时,才会显式向其他核心派发从属任务(Slave Task)。 ```mermaid flowchart LR accTitle: TempleOS 与 Linux 多核利用模型对比 accDescr: 对比 TempleOS 针对单个程序的多核 CPU 渲染与 Linux 面向多应用的并发调度 subgraph TempleOS["TempleOS (单应用极致加速)"] Core0["Core 0 (Master 任务)"] Cores["Core 1-7 (Slave 任务: CPU 图形并行渲染)"] Core0 -->|"直接分配任务"| Cores end subgraph Linux["标准 Linux (多任务分时运行)"] Sch["内核调度器"] AppA["应用 A (独占单核)"] AppB["应用 B (独占单核)"] GPU["GPU (图形渲染下放)"] Sch --> AppA Sch --> AppB AppA -.-> GPU end ``` Terry 演示了他的飞行模拟器,该程序直接动用了 8 个 CPU 核心进行纯软件图形渲染。他反驳 Linus 所谓“并行只对图形有用”的说法,指出在 Linux 生态中图形渲染全被甩给了独立的 GPU,导致 CPU 往往只能闲置或跑单个核心,而 TempleOS 则是让 CPU 亲自完成渲染运算。Terry 进一步抨击现代调度器的不可控性:如果调度器自作主张把两个图形渲染任务塞进同一个核心,帧率就会立刻从 30 帧暴跌至 15 帧。在多核的有效利用效率上,Terry 表达了极端的嘲讽: > “Linux will run two applications faster, TempleOS can run one application fast.” —— Terry Davis - TempleOS 是专为“单个多线程游戏/应用榨干所有核心”设计的,绝不妥协去兼顾“同时跑两个大游戏”。 - 传统系统的动态调度存在严重的不确定性,会导致帧生成时间剧烈波动。 - TempleOS 完全由应用显式指定哪项计算落在哪个物理核上,从根本上消除了调度冲突。 --- ### [24:19](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1459s) 小即是美:命名空间、全局变量与底层编程的遗失 在讨论系统规模与软件工程规范时,Terry 指出系统缩小后会带来质的飞跃。相比于 Linux 动辄两千万、四千万甚至五千万行的庞大代码库,TempleOS 将整机规模严格限制在 10 万行代码左右。Terry 认为代码量过大迫使人们引入复杂的命名空间(Namespaces)和冗长的变量名;而在精巧的系统里,单一大命名空间和短变量名才是最优雅、最舒适的解决方案。 随后,Terry 打开了一个仅有 188 行代码的简单游戏代码,借此痛斥现代软件工程对“全局变量”的污名化。他认为当系统规模适中时,全局变量就是最直观、最正确的选择。现代计算机教育一味推崇高级抽象、屏蔽底层细节,搞得新手既不懂指针,也不懂汇编指令,甚至连内存分配都搞不明白。关于底层概念的学习,Terry 尖锐地批评道: > “They're making it so that nobody has any clue what really goes on, you know it's a liberal with their bleeding heart trying to be nice to the poor people they're making it worse, just man up and learn what malloc and free are.” —— Terry Davis - **对 Linus 与编程语言的态度**:尽管抨击 Linux,Terry 表示自己依然欣赏 Linus Torvalds 坚持使用 C 语言、坚决排斥 C++ 的立场;不过 Terry 本人倾向于带有轻量级扩展的 C/C++ 风格,同时对学术界“有了成果就发论文”与工业界“有了好东西就当秘密封锁”的两极做法都表示厌倦。 - **极简 API 设计**:TempleOS 引入了 64 位整型的日期时间表示(Date-Time),并大量采用简短精炼的函数名与变量名,按下 F1 即可呼出全局帮助系统,旨在让每个普通人都能像当年摆弄 Commodore 64 一样,把整台电脑的内部机制彻底装进脑子里。 ## Notable quotes > [17:47](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1067s) An idiot admires complexity, a genius admires simplicity, a physicist tries to make it simple anyway. — Terry Davis > [00:00](https://www.youtube.com/watch?v=gBE6glZNJuU&t=0s) Linux 是半挂式卡车(Semi-truck),Windows 是轿车,而 TempleOS 是一辆摩托车。 — Terry Davis > [00:00](https://www.youtube.com/watch?v=gBE6glZNJuU&t=0s) 如果你在摩托车上倾角过大,它就会摔毁;这很疯狂吗?别那么做就是了。 — Terry Davis > [21:53](https://www.youtube.com/watch?v=gBE6glZNJuU&t=1313s) Linux will run two applications faster, TempleOS can run one application fast. — Terry Davis > [08:56](https://www.youtube.com/watch?v=gBE6glZNJuU&t=536s) 当你只是在循着别人的足迹行走时,你根本不是一个开拓者。 — Terry Davis > [12:17](https://www.youtube.com/watch?v=gBE6glZNJuU&t=737s) 在 Linux 上,任务切换有巨大的开销;他们每次切换任务都必须保存 CR3,必须更换整个内存映射。我不更换内存映射,我也不切换特权级别。 — Terry Davis ## Mentioned Terry Davis, Linus Torvalds, TempleOS, Linux, Windows, Commodore 64, BASIC, C, C++, Nikola Tesla, Westinghouse Electric, CERN, NASA, Trivial Solutions, Bill Gates, Vincent Canfield ## Video description This is an archive channel dedicated to hosting all of Terry A. Davis' old videos before he deleted his channel. Full credit for saving these goes to Vincent Canfield https://vc.gg/templeos/ I just upload them to YouTube. Other archive channels that upload from his website: https://www.youtube.com/channel/UC7XZSFX4YhqzXbt513F2sEA (this one is fully automated) https://www.youtube.com/channel/UC2JvKvUmoWdtE55ta15a3tg https://www.youtube.com/channel/UCEPEqMr199q3iRTwToIotVA Vice article on Terry A Davis: https://motherboard.vice.com/en_us/article/wnj43x/gods-lonely-programmer Terry's official website: http://www.templeos.org/ [Source](https://www.youtube.com/watch?v=gBE6glZNJuU)

Source quotes

[17:47] Terry Davis: An idiot admires complexity, a genius admires simplicity, a physicist tries to make it simple anyway. [0:00] Terry Davis: Linux 是半挂式卡车(Semi-truck),Windows 是轿车,而 TempleOS 是一辆摩托车。 [0:00] Terry Davis: 如果你在摩托车上倾角过大,它就会摔毁;这很疯狂吗?别那么做就是了。 [21:53] Terry Davis: Linux will run two applications faster, TempleOS can run one application fast. [8:56] Terry Davis: 当你只是在循着别人的足迹行走时,你根本不是一个开拓者。 [12:17] Terry Davis: 在 Linux 上,任务切换有巨大的开销;他们每次切换任务都必须保存 CR3,必须更换整个内存映射。我不更换内存映射,我也不切换特权级别。

Source quotes

[0:00] Terry Davis: Linux is the semi, Windows is a car, TempleOS is a motorcycle. [17:47] Terry Davis: I'm making a Commodore 64; I don't do sharing. [12:17] Terry Davis: I can save tasks and switch tasks faster than I can read a port. [24:19] Terry Davis: Nobody knows what a pointer is, nobody knows what assembly code is, they've all been so confused by the liberals trying to make it easy for them.

Original transcript

[0:00] okay so I'm going to talk about right - [0:06] discussing spin locks [0:08] spin locks anyway so I'm just going to [0:12] give a little lecture here so Linux [0:20] Linux wants to be a 1970s mainframe so [0:29] being frame had limited resources let's [0:32] say about two Meg of RAM and they had to [0:36] operate with a hundred users and if it [0:40] crashed [0:40] that was terrible you would never want [0:42] to crash my my operating system wants to [0:47] be a Commodore 64 and then a Commodore [1:02] 64 user in the users manual that tells [1:06] how to make binary numbers to make a [1:09] sprite graphic so the users the purpose [1:13] was to make sprite graphics with binary [1:15] data that's what you did with a [1:18] Commodore 64 little basic programs and [1:21] stuff so those are that's now I like to [1:29] say Linux Linux is the semi Windows is a [1:35] car temple OS is a motorcycle the reason [1:45] I call Linux Linux a semi a semi had has [1:49] 20 gears and that's never going to be a [1:54] passenger car file permissions that does [1:59] not belong in a consumer product file [2:04] probably it's a big hassle so that the [2:08] Linux people are all deluded anyway [2:12] so you don't have side airbags no side [2:18] airbags you know what's pretty crazy if [2:23] you lean over on a motorcycle it crashes [2:27] isn't that crazy [2:29] don't do that I can crash my operating [2:33] system pretty easily but that's not [2:37] that's not very interesting anyway uh so [2:44] let me just tell you something uh if I [2:49] had to summarize how people think well [2:54] first of all everybody is fighting the [2:57] last war everybody is looking at 1970s [3:00] mainframes and if you if anybody was [3:07] discussing my operating system you can [3:10] bet they would be reinventing a 1970s [3:13] mainframe first of all the mainframe had [3:16] to Meg for a hundred users it goes [3:23] without saying you have to use virtual [3:25] memory that's where you use the disk not [3:29] on today's computers you have a gig [3:34] every anyway so you don't have if you [3:39] ever do cause it to start swapping to [3:45] disk it's way too slow to be acceptable [3:49] if anybody today started swapping to [3:53] disk they would say oh this is [3:54] unacceptable we need to change something [3:57] so virtual memory that doesn't belong on [4:01] a modern computer I'm interested in [4:06] having pretty code anyway uh so I'm not [4:12] talking about paging I'm talking about [4:13] virtual memory virtual memory is where [4:15] you swap to disk anyway of but there's [4:18] other things if you have two Meg for a [4:22] hundred users [4:24] when you're compiling you better not use [4:28] up very much memory because that's rude [4:33] but on my operating system I I load [4:40] whole files this is a totally different [4:44] way of thinking on Linux you use a pipe [4:47] you load a little chunk then you process [4:49] it then you load a little chunk and you [4:52] process it on my operating system I have [4:55] loaded whole files so uh what am I [5:00] trying to achieve my highest ideal is a [5:05] minimum lines of code lines of code so [5:10] if you have to make a choice pick the [5:12] one that uses less code because we want [5:16] our our vision is account or 64 and on a [5:20] Commodore 64 it was user this is up on a [5:24] patent this willing to make a trademark [5:26] user developer okay user developer the [5:33] Commodore 64 was a user developer [5:35] machine okay so uh as a matter of fact I [5:40] am really close to banning third-party [5:45] developers my if I have to make a choice [5:51] I picked the user developer over the [5:54] third-party developer so I set a goal I [5:58] set a limit of a hundred thousand lines [6:00] of code and no third-party libraries [6:06] okay my vision is a Commodore 64 and [6:12] that had a ROM 20k ROM and everybody [6:18] brought with them everything they needed [6:23] so here's here's what I want to say all [6:28] all computer people today have been Jedi [6:32] Mind tricked they obsess on if there's [6:38] one thing they all want to show you that [6:40] they know is scaling scaling everybody [6:45] is obsessed with scaling guess what [6:48] scaling works both ways you can get [6:53] bigger what happens if you look the [6:56] other direction and you're scaled down [6:59] everybody knows it doesn't get bad it [7:07] gets worse when you scale up it doesn't [7:12] get bad it gets worse in other words [7:16] it's not linear guess what it doesn't [7:21] just get better it gets well I don't [7:24] have a word it gets better when you [7:27] scale down so guess what a linker if I [7:33] don't have a linker on my system I just [7:37] you know how when you do CC I don't know [7:40] test dot C and it makes an a dot out [7:45] that's kind of how we operate we hit f5 [7:49] and we don't have a linker we don't have [7:52] a make utility do you want to know it's [7:55] funny [7:55] once you want to see how I do a project [7:58] I make a file with this is including [8:03] code this is not headers this is [8:06] hilarious anybody do you think that's [8:08] funny you want to see me do a make off [8:11] okay I want to do a make all I hit my I [8:13] have one key that's make all I just made [8:17] a 50,000 lines of code and that's I just [8:26] compiled from scratch fifty thousand [8:29] lines of code my kernel is twenty [8:32] thousand my compiler is twenty thousand [8:35] so fifty thousand anyway so that's all [8:39] the code there is everything else is [8:41] just in time and you saw how fast that [8:43] was a second to do that the atom [8:46] directory gets compiled during boot this [8:48] is Adam as in Adam and Eve [8:51] anyway so everybody else has been Jedi [8:55] mind-trick [8:56] this is funny when I tell people that I [9:01] said a 2gig limit for codes okay there's [9:07] a call instruction called relative 32 [9:10] and my operating system is 64-bit but I [9:16] purposely use only call relative 32 and [9:20] I put all code in the lowest two gig [9:24] this instructions there's not there's [9:27] not a 64-bit call instruction what you [9:30] have to do is you have to move it into [9:33] RA x1 do 3 4 you have to move it into RA [9:39] X and then do a call ra X and look at [9:45] this this takes up I don't know 10 bytes [9:47] this instruction is 10 bytes and this [9:50] instruction is whatever 3 bytes [9:53] something like that 3/4 anyway my call [9:56] relative is 5 so I'm looking at a lot [10:00] fewer bytes anyway and it's faster so [10:06] when I tell people I'm making a 2 gig [10:09] limit do you know what they're thinking [10:10] in their minds they have been Jedi mind [10:14] trick bahahaha [10:17] Bill Gates is so stupid [10:21] he said 640k would be enough he is just [10:26] stupid bah ha ha ha [10:29] so when I say 2 gig they say we're not [10:33] that stupid [10:34] we know it's never enough ok well these [10:41] are obviously not the sharpest sharpest [10:43] knife in the drawer [10:44] ok people what is what is enough you [10:48] know what I'm saying like that's the [10:52] difference in sheep and Shepherds Linux [10:57] is a UNIX it's not really original [11:03] so yeah there I kind of laugh at people [11:07] who it's imagined in 1900 imagine a [11:13] hotshot engineer at I don't know a [11:16] Westinghouse or something [11:18] hotshot electrical engineer and imagine [11:21] him making fun of Tesla I'm just saying [11:24] some some hotshot hotshot engineer I'm [11:29] better than Tesla I know math and him [11:37] being really arrogant and then you're [11:39] saying dude you are no Tesla anyway so [11:47] there's a lot of people who are really [11:49] arrogant and you know physicists where [11:52] there are 2,000 physicists at CERN or [11:55] not CERN I don't know just 2,000 [11:57] physicists not one of them is famous [12:00] because they haven't done anything [12:01] original yet a lot of them are walking [12:04] around as though they're in the same [12:06] league as Tesla now there's a difference [12:09] when it's not when you're following a [12:11] trail you're not a trailblazer so you [12:17] know it's funny um let's just say let's [12:22] say import well let's say let's say [12:30] we're reading a status let's do a little [12:34] analysis let's say you're doing a hard [12:40] bird driver and you're waiting on a disk [12:44] to be ready okay so you do an import on [12:50] a status I oh and if it's not ready [12:57] if status and busy so we read a port and [13:05] if it's busy we yield [13:10] let's do a little analysis of this okay [13:14] first of all import just a rule of thumb [13:19] ISM is an in or out instruction is one [13:22] microsecond in or out is one microsecond [13:28] yield that's where you save all your [13:32] context and load all your context okay [13:39] Linux has a large overhead for context [13:48] they have to save the cr3 they have to [13:53] change their entire memory map every [13:56] time they change tasks I don't change my [13:59] memory map and I don't I don't change [14:02] privilege levels anytime you change [14:05] privilege levels it has to load and save [14:07] stuff and check stuff um this is going [14:11] to blow people's minds I can do you want [14:18] to know how many save restores I can do [14:20] I can do four million savory stores per [14:24] second this is hilarious I can save [14:30] tasks and switch tasks faster than I can [14:33] read a port okay reading the port is a [14:38] million I can I can do four point five [14:42] if you want to see me do it watch this [14:44] okay so here's my context swaps we're [14:49] doing 10,000 that's because I'm writing [14:51] I'm making a video as we speak so let's [14:55] go ahead and say wild true yield [15:02] I don't need parentheses okay watch this [15:05] okay we're doing well we're not hitting [15:11] four or five but we're not doing too bad [15:14] okay so let's do some analysis I can [15:20] believe it or not I can get I can [15:23] a lot of let's do it let's talk about [15:25] SMP okay well first of all so my vision [15:31] is a motorcycle so what do I mean by [15:35] that a lot everybody who is a Linux [15:40] person would move heaven and earth just [15:43] so that you can play two video games at [15:46] once they they they're full of pride [15:50] it's like Russians okay NASA spent [15:55] millions to make a Space Pen Russia used [15:58] a pencil that's kind of the foolishness [16:01] that's not that's a fable it's not a [16:03] true fable and it's not necessarily [16:07] something to be proud of I called my [16:09] company trivial solutions [16:11] well pencil would be a trivial solution [16:13] I don't use privilege levels and anyway [16:19] so uh so on mice this is all the tasks [16:24] these these are all the tasks there's [16:26] one let's call it sir there's one master [16:30] tasks for you I don't know what it's [16:32] called a set task Adam is the first task [16:35] his children are set for the different [16:38] course anyway uh so the set tasks in the [16:43] Adam task so anyway I have eight cores [16:47] and they're all they have one [16:49] I guess called an executive task um so [16:53] uh on my core zero my core zero I have I [17:02] have a window manager which is in charge [17:05] of painting the window this is my frame [17:09] grabber and this is the TAT this is the [17:11] current task that were the task ID [17:15] that's the address of the task record [17:20] anyway and then I have my Adam task so [17:24] on a typical let's say you run a game [17:28] that's that's what this is for running [17:31] games like a Commodore 64 what are you [17:34] going to do maybe you make [17:37] animation tasks so basically you're [17:41] going to run one application at a time [17:43] and it might be multi-threaded on this [17:47] operating system everything uses the [17:50] same memory map so there's not a [17:53] distinction between process and thread [17:55] there's not in tasks there's just [17:59] there's no distinction you know in [18:01] fairness of okay so when I'm waiting for [18:06] my disk I do well import yield okay and [18:17] what it let's analyze this this is I [18:20] don't know I don't care you know [18:22] somebody's going to call it blocking its [18:24] these little brainwashed book people who [18:27] couldn't its Tesla being mocked by you [18:31] know somebody you think it reads a book [18:33] you know say if you got it out of a book [18:36] yeah whatever [18:37] so I adapt to a new reality they're all [18:42] fighting the last war they're making [18:44] 1970s mainframes I don't know why and [18:47] they're mocking me so I can I can save [18:52] tasks Oh what let's analyze this if we [18:55] have five tasks and I do a round robin I [18:59] don't do priorities is it because I [19:05] can't do priorities no it's because an [19:09] idiot admires complexity a genius admire [19:13] simplicity a physicist tries to make it [19:16] simple anyway an idiot anything the more [19:21] complicated is the more he will admire [19:23] it if you make something so cluster [19:26] [ __ ] he can't understand it he's going [19:29] to think you're a god because you made [19:30] it so complicated nobody can understand [19:33] it that's all the right journals and [19:36] academic journal [19:38] they they try to make it so complicated [19:40] people think you're a genius [19:43] okay anyway so if I have five tasks [19:48] let's say two of them wanna listen [19:50] long story short when you're waiting for [19:53] a key it it's it doesn't get swapped in [19:57] until I forgot all that works anyway [20:04] yeah keys and there's if you're waiting [20:06] for a message it it's permanently [20:09] swapped out if you're waiting for a time [20:12] a jiffy [20:13] it's permanently swapped out when it [20:18] goes around the circle scheduling [20:23] sometimes it will never load it until [20:26] it's ready on other things that will [20:29] load it in check and then the task will [20:31] swap out again if you have two tasks [20:34] reading from the disk both of them are [20:36] operating this code now let's analyze [20:39] that if one is ready then it gets [20:43] swapped in then and when it has to wait [20:47] to come back around the circle of tasks [20:50] it's a let's say you have five tasks [20:53] you're going to take five times a [20:56] quarter of a microsecond so it's going [21:00] to take you a microsecond it's not it's [21:03] not just in other words if you swap out [21:06] it's not if you have five tasks if [21:11] divide this by 5 so what if you have a [21:16] hundred tasks now it's beginning to be a [21:19] serious problem but that's not my [21:22] concern I'm making a Commodore 64 [21:25] I don't do sharing so if your task is [21:29] doing 20 mega [21:31] disk read then you've got you lock it [21:35] out from anybody else [21:37] my vision is a single video game running [21:40] with multiple threads and I don't I'm [21:46] not trying to run two video games at [21:48] once you know that's that's [21:53] anyway so another thing is SMP this is [21:57] kind of hilarious this is going to shock [21:59] you I think just to make people shocked [22:02] you know Linus the other day mentioned [22:04] that multi-core was overrated well this [22:12] is I'm not going to show you long story [22:16] short I my plan is master slave so what [22:22] that means is of all all applications [22:25] run on core zero and when they want [22:29] multi-core they make a slave task on [22:33] another court directly so for example I [22:39] have eight cores this flight simulator [22:43] is running on eight cores Linus said the [22:47] only thing that parallel is good for his [22:49] graphics well he's using a GPU so he's [22:53] only using one core on the CPU I I do my [22:57] graphics with the CPU so I can actually [23:00] use some now if I had if I have seven [23:04] tasks doing graphics what if one of them [23:09] what if the scheduler puts two of them [23:11] on one core that's just not going to [23:15] work because we need updates if if the [23:19] scheduler decided to put two on one core [23:22] you just it's you just blew your so [23:25] instead of 60 frames per second right I [23:27] do 30 instead of 30 frames per second [23:30] you're doing 15 frames a second just [23:32] because the scheduler put two on one [23:34] core that is just not acceptable so if [23:38] you want to do multi-core Temple OS is [23:41] the only one that can use multi-core [23:43] effectively Linux will run Linux will [23:48] proudly run two applications faster [23:55] they're very proud that can run two [23:58] applications faster tempo OS can run one [24:04] application fast [24:08] temple OS can only run one application [24:11] factor Linux can run two applications [24:15] faster their genius is okay anyway so [24:19] how about that so everything gets [24:23] smaller when it gets better it doesn't [24:26] just get bad when you scale up it gets [24:28] worse doesn't just get better when you [24:31] scale down namespaces if you have we can [24:35] look at my namespace these are all the [24:40] symbols in the symbol tables it's [24:43] getting up there what are we at we're at [24:46] I'm trying to I why doesn't show me line [24:49] to code oh well Oh what is the line [24:54] number I forgot I'm in the editor am I [24:57] not I'm spacing out I could swear I have [25:04] a line a line counter lies on the lines [25:07] anyway so this is all my symbols if you [25:13] if you keep it small you only need one [25:16] namespace if you keep it small okay this [25:20] is me I know somebody's going to [25:21] contradict me okay so when it gets big [25:26] you have to adapt and change your way of [25:29] programming to use namespaces long [25:33] variable names see unfortunately you [25:36] can't get people to go the other [25:38] direction if you have a my operating [25:41] system is a hundred thousand lines of [25:43] code Linus is very proud that his is 50 [25:47] million anyway I don't know 40 million [25:51] 20 million he's trying to make it bigger [25:54] to intimidate people or something anyway [25:59] so if you make it small you can use the [26:03] variables okay there are arrogant people [26:07] who let's say you're you're making a [26:14] game for [26:16] kids you're a kid you're making a game [26:19] it's it's a couple-hundred it's honor [26:21] what are we we're at 188 lines of code [26:24] that was that's what wasn't showing them [26:28] okay 180 lines of code now our global [26:32] variables the right or the wrong answer [26:35] for this situation there are a lot of [26:38] people who will say oh you shouldn't use [26:42] global variables you're not going to be [26:45] a good programmer if you learn that way [26:48] yeah we all started with calendar 64th [26:51] nobody nobody knows where a pointer is [26:53] nobody knows what assembly code is [26:56] they've all been so confused by the [26:58] Liberals trying to make it easy for them [27:01] I don't understand how you can make [27:03] malloc and free simpler if you they're [27:07] making it so that nobody has any clue [27:10] what really goes on you know it's a [27:13] liberal with their bleeding heart trying [27:15] to be nice to the poor people they're [27:17] making it worse just man up and learn [27:22] what malloc and free are I like Linus [27:26] because he likes C and doesn't like C++ [27:29] I like C++ but I'm impressed by I like [27:34] industry not academia anyway in industry [27:40] in academia if it's good you publish in [27:45] industry if it's good you keep it a [27:47] secret [27:47] it's anyway so I don't actually like [27:52] that attitude anyway um so global [27:57] variables are the right answer now the [28:00] second question is long variable names [28:05] if you scale down the right answer is [28:09] short variable names and function names [28:13] so I've been um f1 is my help I want [28:21] this so that everybody can get their [28:22] head around it like a Commodore 64 so um [28:28] I'm trying to make short names are [28:31] delightful you know that there there's [28:34] just something very nice about short [28:36] variable names I did 64-bit date times [28:39] now isn't that cool let's just look at [28:43] some of my other short names anyway oh [28:47] whoa [28:48] so that's that