Week 27: Memory Virtualization

Memory virtualization provides another layer of abstraction from the physical memory called address space. Programs use a stack to keep track of where it is in the function chain, allocate local variable,s and pass parameters, and returns values to and from routines. Heap is used for dynamically-allocated, user-managed memory for system calls like malloc in C. Although, programs don't actually reside in the physical address space but rather in a virtual address.

Initial takeaways:

  • Virtual memory provides transparency, efficiency, and protection. This also allows programs to be isolated and safe from other faulty or malicious processes.
  • There are two types two memory: stack, which is handled by the compilers, and heap memory which is dealt with by the programmer.
  • In C: malloc(size_t size) function allows the programmer to ask for a specific amount of memory. For some routines, you may run into errors where you may not have allocated memory or too little was allocated.
  • Free () - allows the programmer to free heap memory no longer in use. Not using free may result in a memory leak.

Using hardware-based address translation(address translation) can transform memory access from virtual to physical. However, hardware only provides low-level mechanisms for doing so efficiently; the OS actually sets up the hardware to correctly perform the translation and manage memory, such as keeping track of free locations in use.

Dynamic Relocation or base and bounds is a technique that requires two hardware registers within each CPU.