Leanpub Header

Skip to main content

FROM RUNTIME TO DISTRIBUTION

VOLUME I

FROM RUNTIME TO DISTRIBUTION
This book is 100% completeLast updated on 2026-08-19

Go beneath C# and .NET—from CPU, kernel, processes and threads to IL, JIT, native code, stacks, heaps and GC. Build the runtime mental model you need before deciding where, why, and whether a system should be distributed.

Minimum price

$100

$149

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
About

About

About the Book

What actually happens between a line of C# and the machine that finally executes it?

Most .NET books begin where application developers are already comfortable: classes, APIs, frameworks, dependency injection, databases, web endpoints. From Runtime to Distribution goes in the opposite direction. It moves downward through the layers that make those abstractions possible—CPU execution, operating-system boundaries, processes, threads, virtual memory, the CLR, IL, JIT compilation, native code, stack frames, managed heaps, and garbage collection.

The purpose is not to turn a software engineer into an operating-system researcher or CLR implementer. It is to build a sufficiently precise mental model of the machine beneath .NET so that architectural decisions can be made with fewer myths and fewer hidden assumptions.

The book begins with the most fundamental question: what actually runs when a program runs? From there it follows the execution path from source code toward hardware. Processes and threads are separated carefully. User mode and kernel mode are treated as real protection boundaries rather than vague terminology. Context switches and scheduling are connected to the practical cost of excessive concurrency.

The journey then enters the .NET runtime itself. Assemblies, metadata, types, IL, the evaluation stack, assembly loading, JIT compilation, tiered compilation, PGO, ReadyToRun, Native AOT, and native machine code are examined as parts of one execution pipeline. The emphasis is always on understanding why the runtime exists, what work it performs, and where managed abstractions eventually meet the processor.

The final part turns to memory.

Rather than repeating simplified slogans such as “value types live on the stack” or “the heap is slow,” the book develops a more useful model of stack frames, roots, reachability, managed allocation, generations, LOH, POH, finalization, unmanaged resources, memory pressure, allocation storms, Workstation GC, Server GC, and Background GC.

That leads to the architectural question that prepares the ground for the next volume:

What changes when one process becomes many processes?

A single .NET process has process-local runtime state and GC-managed memory. Ten independently running service processes create ten independent runtime environments—with their own allocation behavior, collection pressure, caches, pools, stacks, and failure boundaries. Distribution can isolate some problems, but it also introduces serialization, queues, retries, duplicated runtime state, network latency, and operational complexity.

The book therefore does not present microservices as an automatic improvement. It first establishes what exists before distribution begins, so that later architectural boundaries can be evaluated against the runtime realities underneath them.

Four visual checkpoints compress the major transitions:

  • One Program — Many Layers
  • One Core, Two Threads, One Context Switch
  • C# → IL → JIT → Native Code → CPU
  • One Large Heap vs Ten Independent Heaps

The result is a bridge between low-level systems knowledge and everyday .NET architecture.

From Runtime to Distribution is Volume I of the NEXUS-1 Systems Trilogy. It is written for .NET developers, software architects, technical leads, and engineers who want to understand not only how to use the runtime, but what the runtime is actually doing beneath their code.

The central question of the volume is simple:

Before we distribute a system, do we really understand the machine we are distributing?

Author

About the Author

Grigorios Agathangelidis

My name is Grigorios Agathangelidis, and my professional background is in Electrical Engineering and Software Engineering. Much of my work has focused on .NET, distributed systems, software architecture, domain modeling, and the engineering of systems whose behavior must remain understandable beyond the abstractions presented by frameworks.

From Runtime to Distribution grew from a simple engineering question: how confidently can we reason about distributed software if we do not first understand what a single process, thread, runtime, heap, and CPU are actually doing beneath our code?

That question led me downward through the stack—from C# and the CLR to IL, JIT compilation, native machine code, operating-system boundaries, scheduling, virtual memory, stack frames, managed allocation, and garbage collection. The purpose was not to reproduce an operating-systems textbook or document every internal CLR implementation detail. It was to build the level of systems understanding that I believe is especially valuable to working software engineers and architects.

My broader engineering approach is strongly influenced by the idea that abstractions are useful only while their boundaries remain understood. Frameworks allow us to work at remarkable levels of productivity, but architecture eventually encounters physical realities: execution consumes CPU time, threads are scheduled, memory is finite, processes fail, garbage collectors pause, messages cross isolation boundaries, and distribution introduces costs that cannot be removed by terminology.

This book is part of the wider NEXUS-1 body of work, which explores complex systems through software architecture, systems engineering, simulation, causal reasoning, domain-driven design, distributed systems, and formal methods. Across that work, I try to preserve the same principle: separate what is modeled from what is measured, what is specified from what is demonstrated, and what an abstraction promises from what the underlying machine actually guarantees.

I approach these subjects primarily as an engineer rather than as an academic specialist in operating-system or runtime implementation. Where behavior is platform-specific or implementation-dependent, I try to identify that boundary rather than turn one implementation detail into a universal rule.

The aim of From Runtime to Distribution is therefore not to make the reader memorize runtime internals. It is to help software engineers develop a stronger mental model of the machine underneath .NET—one that makes later decisions about concurrency, performance, memory, process boundaries, containers, and microservices more deliberate.

For me, this volume represents an important transition in the NEXUS-1 work: from understanding software architecture mainly through application-level structures to examining the execution machinery underneath them.

Because before asking how a system should be distributed, I believe an engineer should first be able to answer a more fundamental question:

What exactly are we distributing?

Author: Grigorios Kyriakos Agathangelidis
Greek name: Γρηγόριος Κυριάκος Αγαθαγγελίδης
Also searchable as: Αγαθαγγελίδης Γρηγόριος, Αγαθαγγελιδης Γρηγοριος, Grigorios Agathangelidis.

Contents

Table of Contents

  • Front Matter
    • Cover
    • Standing Boundary and Copyright Note
    • Preface — The Boundary the Diagram Hides
    • Contents
    • The Execution Map: From C# to CPU
  • Part I — The Machine Below the Application
    • Chapter 1 — What Actually Runs When You Run a Program?
    • Chapter 2 — From Source Code to a Running Machine
    • Chapter 3 — The CPU: The Place Where Software Finally Becomes Work
    • Chapter 4 — Memory: Addresses Before Objects
    • Chapter 5 — What an Operating System Actually Does
    • Chapter 6 — User Space and Kernel Space
    • Visual I — One Program — Many Layers
  • Part II — Kernel, Process, and Thread
    • Chapter 7 — The Kernel: The Privileged Core
    • Chapter 8 — Kernel Architecture: Monolithic Kernels and Microkernels
    • Chapter 9 — The Shell Is Not the Kernel
    • Chapter 10 — System Calls: Crossing into the Kernel
    • Chapter 11 — Interrupts, Exceptions, and Traps — A Practical Introduction
    • Chapter 12 — What Is a Process?
    • Chapter 13 — The Process Control Block
    • Chapter 14 — Virtual Address Space
    • Chapter 15 — What Is a Thread?
    • Chapter 16 — From Managed Thread to OS Thread
    • Chapter 17 — Scheduling
    • Chapter 18 — Context Switching
    • Chapter 19 — The Hidden Cost of Too Many Runnable Threads
    • Chapter 20 — Windows and Linux: Different Implementations, Shared Ideas
    • Visual II — One Core, Two Threads, One Context Switch
  • Part III — Inside the .NET Runtime
    • Chapter 21 — Why .NET Needs a Runtime
    • Chapter 22 — Assemblies, Modules, Metadata, and Types
    • Chapter 23 — C# Becomes IL
    • Chapter 24 — Learning to Read IL Without Becoming an IL Programmer
    • Chapter 25 — The Evaluation Stack
    • Chapter 26 — Loading an Assembly
    • Chapter 27 — JIT Compilation
    • Chapter 28 — From IL to Native Machine Code
    • Chapter 29 — Assembly Language — Only Where It Explains Something
    • Chapter 30 — Tiered Compilation, Optimization, and PGO
    • Chapter 31 — ReadyToRun and Native AOT
    • Chapter 32 — Method Calls All the Way Down
    • Visual III — C# → IL → JIT → Native Code → CPU
  • Part IV — Memory and the Garbage Collector
    • Chapter 33 — Stack and Heap Without Mythology
    • Chapter 34 — Stack Frames
    • Chapter 35 — The Managed Heap
    • Chapter 36 — Allocation Is Cheap — Until It Is Not
    • Chapter 37 — Roots and Reachability
    • Chapter 38 — Generations 0, 1, and 2
    • Chapter 39 — LOH and POH
    • Chapter 40 — What Happens During a Collection
    • Chapter 41 — Workstation GC, Server GC, and Background GC
    • Chapter 42 — Finalization, IDisposable, and Unmanaged Resources
    • Chapter 43 — Memory Pressure and Allocation Storms
    • Chapter 44 — One Process, One GC Domain
    • Chapter 45 — Ten Services, Ten Heaps
    • Visual IV — One Large Heap vs Ten Independent Heaps
  • Back Matter
    • Glossary
    • Sources and References
    • Index

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub