Skip to product information
Secrets of the Computer's Underside
Secrets of the Computer's Underside
Description
Book Introduction
What happens inside your computer when you run the code?
From the operating system to the CPU, synchronization, and the principles of implementing input/output,
Let's take a look at the secrets under the hood of your computer that will change your code!


We've all probably had the experience of thinking, "Huh? Why isn't this code working?"
Even if your code runs well, you often don't know how it works, what happens internally when your computer runs it, why various problems occur, and how to optimize them.
This book is aimed at developers who are not simply satisfied with the few lines of code running without errors, but rather who think about what is happening inside and what impact it has on the code.

This book examines the structure of a computer system, which is abstracted by layer, one by one.
Starting with programming languages ​​and compilers, we will look at operating systems and processes, threads and coroutines, synchronization, memory, and the principles of implementing CPUs, caches, and input/output.
The internals of a computer system, which may seem difficult to understand, are explained using various everyday metaphors and over 300 illustrations, making it relatively accessible.
Beginner developers can learn basic computer knowledge systematically and easily, and experienced developers can get new ideas while organizing what they already know.
  • You can preview some of the book's contents.
    Preview
","
index
Chapter 1: From Programming Language to Program Execution: This is how it goes.

1.1 What if you invented a programming language?
__1.1.1 Genesis: The CPU is a Smart Idiot
__1.1.2 Assembly language appears
__1.1.3 Low-level layer details vs. high-level layer abstractions
__1.1.4 Full Rules: The Beginning of a High-Level Programming Language
__1.1.5 Inception and Recursion: The Essence of Code
__1.1.6 Making Computers Understand Recursion
__1.1.7 Excellent Translator: Compiler
__1.1.8 The Birth of Interpreted Languages
1.2 How does a compiler work?
__1.2.1 The compiler is just a normal program, nothing special.
__1.2.2 Extracting each token
__1.2.3 What the token is trying to express
__1.2.4 Are there any abnormalities in the generated syntax tree?
__1.2.5 Generating intermediate code based on syntax trees
__1.2.6 Code Generation
1.3 The Unspeakable Secret of the Linker
__1.3.1 This is how the linker works
__1.3.2 Symbol Interpretation: Supply and Demand
__1.3.3 Static libraries, dynamic libraries, and executables
__1.3.4 Advantages and disadvantages of dynamic libraries
__1.3.5 Relocation: Determining the Address of a Symbol at Execution Time
__1.3.6 Virtual memory and program memory structure
1.4 Why Abstraction Is Important in Computer Science
__1.4.1 Programming and Abstraction
__1.4.2 System Design and Abstraction
1.5 Summary

Chapter 2 The program ran, but I don't know what's going on.

2.1 Understanding the Fundamentals of Operating Systems, Processes, and Threads
__2.1.1 It all starts with the CPU
__2.1.2 From CPU to Operating System
__2.1.3 The process is very good, but still inconvenient.
__2.1.4 Evolution from Processes to Threads
__2.1.5 Multithreading and Memory Structure
__2.1.6 Thread Utilization Example
__2.1.7 How the thread pool works
__2.1.8 Number of threads in the thread pool
2.2 Process resources shared between threads
__2.2.1 Thread-only resources
__2.2.2 Code area: All functions can be placed in threads and executed.
__2.2.3 Data area: All threads can access variables in the data area.
__2.2.4 Heap Area: Pointers are the Key
__2.2.5 Stack area: Private data within shared space
__2.2.6 Dynamic link libraries and files
__2.2.7 Thread-only storage
2.3 How exactly should I write thread-safe code?
__2.3.1 Freedom and Constraints
__2.3.2 What is thread safety?
__2.3.3 Thread-specific and shared resources
__2.3.4 Use only thread-specific resources
__2.3.5 Thread-Specific Resources and Function Parameters
__2.3.6 Using global variables
__2.3.7 Thread-only storage
__2.3.8 Function return values
__2.3.9 Calling Non-Thread-Safe Code
__2.3.10 How to implement thread-safe code?
2.4 How should programmers understand coroutines?
__2.4.1 General functions
__2.4.2 From regular functions to coroutines
__2.4.3 Intuitive explanation of coroutines
__2.4.4 Functions are just a special case of coroutines
__2.4.5 History of Coroutines
__2.4.6 How are coroutines implemented?
2.5 Thoroughly understand callback functions
__2.5.1 It all starts with the following requirement:
__2.5.2 Why callbacks are needed
__2.5.3 Asynchronous Callbacks
__2.5.4 Asynchronous callbacks lead to a new way of thinking about programming
__2.5.5 Definition of callback function
__2.5.6 Two callback types
__2.5.7 The Problem with Asynchronous Callbacks: Callback Hell
2.6 Thoroughly understand synchronous and asynchronic
__2.6.1 Hardworking Programmer
__2.6.2 Making phone calls and sending emails
__2.6.3 Synchronous Call
__2.6.4 Asynchronous calls
__2.6.5 Synchronous and Asynchronous Operations on Web Servers
2.7 Oh, right! There are blocking and non-blocking modes.
__2.7.1 Blocking and Non-Blocking
__2.7.2 The Core Problem of Blocking: I/O
__2.7.3 Non-blocking and asynchronous I/O
__2.7.4 Analogy to ordering pizza
__2.7.5 Motivation and Blocking
__2.7.6 Asynchronous and Non-Blocking
2.8 Implementing a server with high concurrency and high performance
__2.8.1 Multiprocessing
__2.8.2 Multithreading
__2.8.3 Event Looping and Event Driven
__2.8.4 First Issue: Event Sources and I/O Multiplexing
__2.8.5 Second Problem: Event Loops and Multithreading
__2.8.6 How a Cafe Works: The Responder Pattern
__2.8.7 Event Cycle and Input/Output
__2.8.8 Asynchronous and Callback Functions
__2.8.9 Coroutines: Asynchronous Programming with Synchronous Methods
__2.8.10 CPU, Threads, Coroutines
2.9 A Computer System Journey: From Data, Code, Callbacks, and Closures to Containers and Virtual Machines
__2.9.1 Code, Data, Variables, Pointers
__2.9.2 Callback functions and closures
__2.9.3 Container and Virtual Machine Technology
2.10 Summary

Chapter 3: Low-Level Hierarchies? Let's start with the locker called memory.

3.1 The nature of memory, pointers and references
__3.1.1 What is the nature of memory? Lockers, bits, bytes, and objects.
__3.1.2 From Memory to Variables: What Variables Mean
__3.1.3 From Variables to Pointers: Understanding Pointers
__3.1.4 The Power and Destruction of Pointers: Capabilities and Responsibilities
__3.1.5 From Pointer to Reference: Hiding Memory Addresses
3.2 What does a process look like in memory?
__3.2.1 Virtual Memory: What You See Isn't Always What You Get
__3.2.2 Pages and Page Tables: From Virtual to Real
3.3 Stack Area: How are function calls implemented?
__3.3.1 Helpers for Programmers: Functions
__3.3.2 Tracing Function Call Activity: Stack
__3.3.3 Stack Frames and Stack Areas: A Macro Perspective
__3.3.4 How are function jumps and returns implemented?
__3.3.5 How are parameter passing and return values ​​implemented?
__3.3.6 Where are the local variables?
__3.3.7 Saving and restoring registers
__3.3.8 Let's draw the big picture, where are we now?
3.4 Heap Area: How is dynamic memory allocation implemented?
__3.4.1 Why we need heap space
__3.4.2 Implementing the malloc memory allocator directly
__3.4.3 From parking lot to memory management
__3.4.4 Managing free memory fragments
__3.4.5 Tracking memory allocation status
__3.4.6 How to choose a piece of free memory: Allocation strategy
__3.4.7 Allocating memory
__3.4.8 Freeing memory
__3.4.9 Efficiently merging free memory fragments
3.5 What happens at the low level when allocating memory
__3.5.1 Heaven, Earth, and Human CPU Execution Status
__3.5.2 Kernel State and User State
__3.5.3 Portal: System Calls
__3.5.4 Standard Library: Hiding System Differences
__3.5.5 When the heap area runs out of memory
__3.5.6 Requesting memory from the operating system: brk
__3.5.7 Beneath the Iceberg: Virtual Memory is the Final Boss
__3.5.8 The Whole Story of Memory Allocation
3.6 How is the memory pool implemented for high-performance servers?
__3.6.1 Memory Pools vs. General-Purpose Memory Allocators
__3.6.2 Principles of Memory Pool Technology
__3.6.3 Implementing a super-simple memory pool
__3.6.4 Implementing a Slightly More Complex Memory Pool
__3.6.5 Thread safety issues with memory pools
3.7 Common memory-related bugs
__3.7.1 Returning a pointer to a local variable
__3.7.2 Misunderstanding of pointer arithmetic
__3.7.3 Dereferencing a problematic pointer
__3.7.4 Reading Uninitialized Memory
__3.7.5 Referencing already freed memory
__3.7.6 Array indexes start from 0
__3.7.7 Stack Overflow
__3.7.8 Memory leak
3.8 Why can't SSDs be used as memory?
__3.8.1 Difference between memory read/write and disk read/write
__3.8.2 Virtual Memory Limits
__3.8.3 SSD lifespan issues
3.9 Summary

Chapter 4: From Transistors to CPUs: Nothing is more important than this.

4.1 This little toy is called a CPU.
__4.1.1 Great Invention
__4.1.2 Logical conjunction, logical conjunction, and logical negation
__4.1.3 The Tao gives birth to one, one gives birth to two, two gives birth to three, and three gives birth to all things.
__4.1.4 Where does computational power come from?
__4.1.5 Amazing memory ability
__4.1.6 The Birth of Registers and Memory
__4.1.7 Hardware or Software? General Purpose Devices
__4.1.8 Basic Hardware Technology: Machine Instructions
__4.1.9 Software-Hardware Interface: Command Set
__4.1.10 Circuits require conductors
__4.1.11 A great achievement, the CPU was born!
4.2 What does the CPU do when it is idle?
__4.2.1 What is the CPU usage of your computer?
__4.2.2 Process Management and Scheduling
__4.2.3 Checking Queue Status: A Better Design
__4.2.4 Everything Returns to the CPU
__4.2.5 Idle Processes and CPU Low Power States
__4.2.6 Breaking the Infinite Loop: Interrupts
4.3 How does the CPU recognize numbers?
__4.3.1 Number 0 and positive integers
__4.3.2 Signed Integers
__4.3.3 Adding a negative sign to a positive number immediately produces the corresponding negative number: Sign-magnitude representation
__4.3.4 Inversion of Sign-Magnitude Representation: 1's Complement
__4.3.5 Adding Two Numbers That Are Not Simple
__4.3.6 Computer-Friendly Representation: Two's Complement
__4.3.7 Does the CPU really know the numbers?
4.4 When the CPU encounters an if statement
__4.4.1 The Birth of Pipeline Technology
__4.4.2 CPU: Megafactory and Pipeline
__4.4.3 If if encounters a pipeline
__4.4.4 Branch Prediction: Make the CPU guess correctly as much as possible
4.5 What is the relationship between the number of CPU cores and the number of threads?
__4.5.1 Recipes and Code, Stir-fries and Threads
__4.5.2 Work Partitioning and Blocking I/O
__4.5.3 Multi-core and multi-threading
4.6 CPU Evolution (Part 1): The Birth of Complex Instruction Sets
__4.6.1 CPU as seen by programmers
__4.6.2 CPU Capabilities: Instruction Set
__4.6.3 Abstraction: Less is more
__4.6.4 Code also takes up storage space
__4.6.5 The birth of an inevitable complex instruction set
__4.6.6 Problems with Microcode Design
4.7 CPU Evolution (Part 2): The Birth of the Reduced Instruction Set
__4.7.1 From Complexity to Simplicity
__4.7.2 Philosophy of the Reduced Command Set
__4.7.3 Difference between complex and reduced instruction sets
__4.7.4 Command Pipeline
__4.7.5 Become world-renowned
4.8 CPU Evolution (Part 2): Counterattack in a Crisis
__4.8.1 If You Can't Beat Them, Join Them: CISC, the Same as RISC
__4.8.2 Hyper-Threading is a killer move
__4.8.3 Taking the Strengths and Compensating for the Weaknesses: Integrating CISC and RISC
__4.8.4 Technology Isn't Everything: The Commercial War Between CISC and RISC
4.9 Mastering the CPU, stack and function calls, system calls, thread switching, and interrupt handling
__4.9.1 Register
__4.9.2 Stack Pointer
__4.9.3 Instruction Address Register
__4.9.4 Status Register
__4.9.5 Situational Information
__4.9.6 Nesting and Stacks
__4.9.7 Function Calls and Runtime Stack
__4.9.8 System Calls and Kernel State Stack
__4.9.9 Interrupts and the Interrupt Function Stack
__4.9.10 Thread Switching and Kernel State Stack
4.10 Summary

Chapter 5: Achieving Big Results with Small Things, Cash

5.1 Cache, the ubiquitous thing
__5.1.1 Speed ​​Differences Between CPU and Memory
__5.1.2 Library, Desk, Cache
__5.1.3 There's No Free Lunch: Cache Refresh
__5.1.4 There's No Free Lunch: Multicore Cache Coherence
__5.1.5 Using memory as a disk cache
__5.1.6 Virtual Memory and Disks
__5.1.7 How does the CPU read memory?
__5.1.8 Distributed storage support
5.2 How to write cache-friendly programs?
__5.2.1 Principle of Program Locality
__5.2.2 Using memory pools
__5.2.3 struct structure relocation
__5.2.4 Separation of hot and cold data
__5.2.5 Cache-Friendly Data Structures
__5.2.6 Traversing a Multidimensional Array
5.3 Multithreaded Performance Inhibitors
__5.3.1 The Basic Unit of Cache and Memory Interaction: The Cache Line
__5.3.2 First Performance Killer: Cache Bounce Issues
__5.3.3 Second Performance Killer: The False Sharing Problem
5.4 The Bonghwaheejehu and the Memory Barrier
__5.4.1 Non-sequential execution of instructions: Compilers and OoOE
__5.4.2 Cache should also be considered
__5.4.3 Four types of memory barriers
__5.4.4 Acquire-Release Semantics
__5.4.5 Interfaces provided by C++
__5.4.6 Different CPUs, Different Natures
__5.4.7 Who Should Care About Instruction Reordering: Lock-Free Programming
__5.4.8 Locking and Lockless Programming
__5.4.9 Debate over command reordering
5.5 Summary

Chapter 6: Is there a computer without input/output?

6.1 How does the CPU handle input/output operations?
__6.1.1 Handling Professionally: Input/Output Machine Instructions
__6.1.2 Memory mapping input/output
__6.1.3 The nature of how the CPU reads and writes the keyboard
__6.1.4 Polling: Keep checking
__6.1.5 Food Delivery Ordering and Discontinuation Processing
__6.1.6 Interrupt-driven I/O
__6.1.7 How does the CPU detect interrupt signals?
__6.1.8 Difference between interrupt handling and function calls
__6.1.9 Saving and restoring the execution status of a suspended program
6.2 What does the CPU do when the disk handles I/O?
__6.2.1 Device Controller
__6.2.2 Should the CPU copy data directly?
__6.2.3 Direct memory access
__6.2.4 Summary of the entire process
__6.2.5 Implications for Programmers
6.3 What happens to a program when it reads a file?
__6.3.1 Input/output from a memory perspective
__6.3.2 How does the read function read a file?
6.4 The Secret to High Concurrency: I/O Multiplexing
__6.4.1 File Descriptor
__6.4.2 How to handle multiple inputs and outputs efficiently?
__6.4.3 Making me call instead of the other person
__6.4.4 Input/Output Multiplexing
__6.4.5 The Three Musketeers: select, poll, epoll
6.5 mmap: Processing Files by Reading and Writing Memory
__6.5.1 Files and Virtual Memory
__6.5.2 Magician Operating System
__6.5.3 mmap vs. traditional read/write functions
__6.5.4 Handling large files
__6.5.5 Dynamic Link Libraries and Shared Memory
__6.5.6 Directly Manipulating mmap
6.6 How much delay will occur in each part of a computer system?
__6.6.1 Convert to time indicator
__6.6.2 Convert to distance indicator
6.7 Summary
","
Detailed image
Detailed Image 1
","
Into the book
In 1984, when I started programming, 8-bit computers were just starting to hit the market in Korea, but in fact, in the US, the 80386 was already in full development following the 80286.
Therefore, it is safe to say that the gap between the domestic computer market and the overseas computer market at that time was well over 10 years.
As I also discuss in this book, at the time, programming was a field accessible only to a very small number of people, and hardware design and structure were needless to say.
So, even though it was extremely difficult to find related materials, it was a time when I had to obtain foreign books one by one through various channels or make copies and circulate them.
One of the foreign books I had at the time was Inside the IBM PC by Peter Norton, known for Norton Utilities.
This book explains in great detail how the PC, which was once considered a strange machine, is structured, what process the keystrokes actually go through internally before being displayed on the screen, and what happens internally in between.
Amazingly, I still have that book.
Even now, I sometimes take it out and read it.
It's such a fun book, and it's one that you discover new things every time you read it.
It seems like we're repeating the same story over and over again, but 30 years ago, using a computer and programming were virtually synonymous.
So every computer user was a potential software developer and hardware developer.
Nowadays, we live in a world where even if there is no TV at home, there are at least a few computers.
Most computer users live lives that have nothing to do with programming.


But if you're holding this book in your hands, you've definitely already stepped foot into the world of programming.
So, rather than simply being satisfied with the few lines of code that are running without errors, I believe that thinking about what's happening inside them and how it affects my code has provided an opportunity for further growth.
I'm proud to say that this book is one of the few that can help you take the first step toward this kind of growth.
This book provides a systematic flow and conceptual understanding to those of you who are tired of looking at information scattered all over the Internet, and it also serves as a guide that sparks curiosity about a world you have never known before.
If this book can help you write code that's even slightly better and more meaningful, it will be a great reward for me, who worked so hard to translate it.
--- From the Translator's Note
","
Publisher's Review
Easy to learn with analogies and pictures
The essence of computer systems


Understanding the inside of a computer changes the code.
A deep understanding of the principles and mechanisms of computer systems can improve the readability and maintainability of the code you write.
In addition, it can effectively optimize program performance and quickly find and resolve code execution errors or abnormal system behavior.
Gain an in-depth understanding of the principles of computer systems.
We will dissect the structure of a computer system, which is abstracted by layer, one by one, starting with programming languages ​​and compilers, and then learning about the operating system, processes, threads and coroutines, synchronization, and memory.
You will also learn about the principles of implementing CPUs, caches, input/output, file systems, networks and communications, security and encryption, and parallel computing.
"]
GOODS SPECIFICS
- Date of issue: March 11, 2024
- Page count, weight, size: 480 pages | 858g | 183*235*20mm
- ISBN13: 9791140708819

You may also like

카테고리