JOS - Memory Management

OS
 
lab
 
computer-architecture
 
memory
 

We continue to explore other aspects of OS memory management: Physical Memory Management, MMU and Virtual Address Space.

We have yet to answer these questions:

  1. How the Operating Systems manages the memory resource;
  2. What happens on each level, when a piece of user software requests a specific memory address. (rephrase)

The first question involves Physical Page Management, and the second one can be illustrated with the graph below:

           (Linear)  +--------------+           +--------+
           Virtual   | Segmentation |  Logical  | Paging |
   User    +------>  |     (LDT)    | +-------> |  (MMU) |
 Software  Address   +--------------+  Address  +--------+

                                                     +
   RAM           Device   +--------+                 |
Memory-mapped <---------+ | CPU    |       Physical  |
  Devices       Commands  |Mapping |  <--------------+
                  or      +--------+       Address

We reviewed Physical Address Space and how CPU maps it to device commands. In this post, we explore the Virtual Address Space and how paging works. We make no distinction between Linear Address and Virtual Address, and ignore segmentation for the context in this post.

Paging was introduced in Intel 80386(also named i386, released in 1985)

Physical Page Management

Continuing from Physical Address Space, we explore how JOS manages the physical memory.

Virtual Memory

Memory Management Unit

https://developer.arm.com/architectures/learn-the-architecture/memory-management/the-memory-management-unit-mmu https://stackoverflow.com/questions/4812137/does-the-mmu-mediate-everything-between-the-operating-system-and-physical-memory virtual addreses should probably introduce MMU (CPU block)

Virtual Address Space

https://www.geeksforgeeks.org/mapping-virtual-addresses-to-physical-addresses/ https://www.geeksforgeeks.org/logical-and-physical-address-in-operating-system/ https://stackoverflow.com/questions/15851225/difference-between-physical-logical-virtual-memory-address PA VA conversion https://stackoverflow.com/questions/5748492/is-there-any-api-for-determining-the-physical-address-from-virtual-address-in-li https://www.cs.miami.edu/home/burt/learning/Csc521.101/notes/virtual-memory-notes.html

https://stackoverflow.com/questions/12040303/how-to-access-physical-addresses-from-user-space-in-linux https://www.eqware.net/articles/CapturingProcessMemoryUsageUnderLinux/index.html

paging

https://www.geeksforgeeks.org/difference-between-paging-and-segmentation/ https://stackoverflow.com/questions/44351461/difference-between-paging-and-segmentation https://stackoverflow.com/questions/24358105/do-modern-oss-use-paging-and-segmentation https://en.wikipedia.org/wiki/X86_memory_segmentation

linux kernel starts at 0xc000 0000, therefore 1 GB kernel 3 GB user (xv6 KERN_BASE starts at 2GB)

(freeBSD also? https://flylib.com/books/en/2.849.1.68/1/)

Intel 64 and IA-32 Architectures Software Developer's Manual - Volume 1 Basic Architecture
    3.3.1 IA-32 Memory Models
    3.3.2 Paging and Virtual Memory

segmentation is enabled by default in protected mode, paging is not, segmentation is legacy