Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Bill Blunden

Rating No ratings yet

Memory Management: Algorithms and Implementation in C/C++ presents several concrete implementations of garbage collection and explicit memory management algorithms. Every implementation is complemented by an in-depth presentation of theory, followed by benchmark tests, a complete listing of C/C++ source code, and a discussion of each implementation's trade-offs.With this book, you can:Find out how memory is managed at the hardware level by the processor.Discover the ways in which different operating systems take advantage of processor facilities to provide memory services via the system call interface.Understand how development libraries and run-time systems build upon the operating system services to manage memory on behalf of user applications.Learn about five complete memory management subsystems that utilize both explicit and automatic collection algorithms.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# Memory Management: Algorithms and Implementation in C/C++ — Reading Guide ## 【One-Line Pitch】 A hands-on, source-code-rich exploration of how memory management really works—from processor paging and operating system policies down to five complete C/C++ implementations of malloc() replacements and garbage collectors—ideal for systems programmers who want to see behind the curtain rather than just read theory. ## 【Book Arc】 - **Opening (~0%–10%)**: The author sets the stage by contrasting academic treatments (which rarely show concrete code) with this book's promise: full implementations, benchmark tests, and trade-off discussions. The table of contents previews the journey from hardware mechanisms through OS policies to manual and automatic memory management algorithms. - **Early (~10%–32%)**: A deep dive into processor-level memory mechanisms—real mode vs. protected mode on Intel architectures, segmentation, paging, page frames, and the GDT/LDT structures. Includes assembly-level examples (e.g., switching to protected mode) and a warning about the dangerous nature of the code (buffer overflows, real-mode vulnerabilities). - **Middle (~32%–48%)**: Operating system memory management policies are examined across several kernels, from simple to sophisticated. Covers DOS extenders (XMS, HIMEM.SYS, EMM386.EXE), the restaurant-like client/driver model, and Linux's minimal GDT approach where all processes share a linear address space but map to different physical regions. - **Late (~48%–60%)**: Security implications surface—Linux Loadable Kernel Modules (LKMs) are shown as a way to bypass memory protection entirely, with the author's "evil laugh" underscoring the power (and danger) of kernel-level access. - **Ending (~60%–100%)**: The book culminates in the promised implementations: manual memory management algorithms (bitmapped allocation, indexed approaches) and automatic garbage collectors, each with theory, C++ source, benchmarks, and critiques. ## 【Key Takeaways】 - **Memory management is a three-layer cake** (Early): hardware mechanisms (segmentation, paging) → OS policies (page tables, GDTs) → application-level allocators. Understanding each layer is essential before writing your own allocator. - **Real mode is "really minimal"** (Early): No memory protection, no paging, only 1MB of DRAM—this explains why early DOS was under 5,000 lines of assembler and why Intel's 80386 introduced protected mode for enterprise viability. - **Paging alone can provide memory protection** (Early): With a flat memory model (one big segment, GDT with three entries), you can disable segmentation-based protection and rely entirely on paging—a key insight for understanding modern OS design. - **The same linear address can map to different physical addresses** (Middle): Page tables and page directories make this possible, which is how Linux runs all processes in one linear space while keeping them isolated in physical memory. - **DOS extender technology was essentially a mini-OS** (Middle): Vendors embedded all memory management components in the application itself, making some extenders nearly complete operating systems—reportedly the precursor to Windows at Microsoft. - **LKMs are a security backdoor** (Middle): Loadable kernel modules become part of the executing kernel, allowing writes to /dev/kmem and modification of internal functions—a powerful demonstration of why kernel memory protection matters. - **Benchmarking methodology matters** (Early): The book emphasizes measuring performance with time-based tests and random variates to create realistic data distributions, not just theoretical complexity analysis. ## 【Reading Tips】 - **Skim the assembly-heavy sections** (Early, ~10%–32%) if you're primarily a C/C++ programmer—the GDT setup and protected-mode switching code is illustrative but not essential for understanding the higher-level algorithms. - **Deep-read Chapter 4 and 5** (the implementation chapters) if your goal is to build your own allocator or garbage collector—these contain the five complete subsystems with full source listings. - **Pay attention to the "NOTE" and "QUESTION/ANSWER" boxes**—they contain the practical insights (like page frame management and linear-to-physical mapping) that tie theory to real systems. - **Take the author's warning seriously**: Use an expendable test machine and implement backup procedures before experimenting with the more dangerous code examples. - **Read the case studies** (COBOL, FORTRAN, Pascal, C, Java) in the opening chapters to understand how language design shapes memory management requirements—this context makes the later implementations more meaningful. ## 【Coverage Limits】 This guide covers the book's structure and key themes from the opening through the middle sections (hardware mechanisms, OS policies, security implications). The detailed implementation chapters (manual and automatic memory management algorithms) are previewed but not summarized in depth, as the excerpts focus primarily on the foundational material. ##
Page 8
2 Language Features . . . . . . . . . . . . . . . . . . 192 Virtual Machine Architecture . . . . . . . . . . . . 194 Java Memory Management . . . . . . . . ....
View in text
Excerpt 2
be the standard amount of DRAM (if we are still using DRAM). Hopefully, someone will not quote me. RAM is not the only place to store data, and this is what...
View in text
Excerpt 3
; enable protected mode bit lmsw ax ; now in protected mode ; perform manual far jump DB 66H DB 67H DB 0EAH ; FAR JMP opcode DW OFFSET _loadshell DW 8H ; 16-...
View in text
Excerpt 4
MMURTL’s memory management approach. Chapter 2 78 Chapter 2 Figure 2.12 NOTE A gigabyte of linear address space does not necessarily trans- late into a gigab...
View in text
Excerpt 5
and protection. Memory Management Policies 111 Figure 2.22 NOTE The exact organization of a program’s code, data, stack, and heap sections are a function of...
View in text
Excerpt 6
piler to compute the size of each activation record and the location of each element in them. These calculations are all per- formed at compile time while th...
View in text
Excerpt 7
e. It is no surprise, then, that Microsoft has begun build- ing some of its primary OS components entirely in C++. For example, a fundamental component of th...
View in text
Excerpt 8
gling pointers are just two of the perils that we have seen. The syntax of C also allows addresses to be cast and moved around so that you might not be sure...
View in text
Tags
AI categories
C++C#OS
ISBN: 1556223471
Publish Year: 2002
Language: English
Pages: 391
File Format: PDF
File Size: 4.0 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…