Suppose a server runs 100 worker processes, all using the same C library. If each process kept its own 2 MiB copy of the library code, that would consume about:
But the code is identical and read-only, so the operating system does not need 100 physical copies.
Instead, each process maps the library into its own virtual address space, while those mappings can point to the same physical pages in memory.
Each process still has its own page tables and virtual addresses. What they share are the physical pages containing the library code.
Shared libraries save memory by letting multiple processes share the same read-only code pages.
Writable state is different. Global variables and runtime data are typically private to each process, often using copy-on-write when needed.
This chapter follows dynamic loading and library mapping, explains position-independent code, relocations, shared read-only pages, and private writable state, and examines accounting, demand paging, runtime loading, updates, and inspection.