9.4.Memory Management

9.4.Memory Management

  • Operating systems provide a separate page table, and thus a separate virtual address space, for each process.

  • Multiple virtual pages can be mapped to the same shared physical page.

   In particular, VM simplifies memory management in the following aspects:

  • Simplifying linking: A separate address space allows each process to use the same basic format for its memory image, regardless of where the code and data actually reside in physical memory.

  • Simplifying loading: When loading the object file into a newly created process, the Linux loader:

    1. allocates virtual pages for the code and data segments

    2. marks them as invalid(i.e., not cached)

    3. points their page table entries to the appropriate locations in the object file.

The loader never actually copies any data from disk into memory.

  This notion of mapping a set of contiguous virtual pages to an arbitrary location in an arbitrary file is known as memory mapping.

  • Simplifying sharing: Rather than including separate copies of the kernel and standard C library in each process, the operating system can arrange for multiple processes to share a single copy of this code by mapping the appropriate virtual pages in different processes to the same physical pages.

  • Simplifying memory allocation: When a program running in a user process requests additional heap space(e.g., malloc), the operating system allocates k of contiguous virtual memory pages, and maps them to k arbitrary physical pages located anywhere in physical memory.