Hasty Briefsbeta

  • #operating-systems
  • #virtual-memory
  • #memory-management
  • Virtual memory is an abstraction that allows processes to access memory as if it were contiguous, even though physical memory may be non-contiguous.
  • Main memory (RAM) is faster than disk storage but volatile, while registers are even faster but limited in size and number.
  • Simple memory allocation strategies like first-fit, best-fit, and worst-fit can lead to external fragmentation, where free memory is scattered and non-contiguous.
  • Paging divides memory into fixed-size blocks (frames in physical memory, pages in virtual memory) to avoid fragmentation and enable efficient memory management.
  • Demand paging loads only the necessary pages into memory, reducing initial load time and memory usage.
  • Virtual memory layout includes segments like the stack, heap, and memory-mapped regions, each serving different purposes in memory allocation.
  • Stack allocation is fast and managed by the compiler, but limited to variables with known sizes at compile time.
  • Heap allocation is dynamic but slower due to the need for mutexes in multithreaded environments and the overhead of managing free lists.
  • Memory mapping allows files or anonymous regions to be mapped into a process's address space, with options for private or shared access.
  • The mmap system call is used to create memory mappings, with the kernel handling address selection and conflict resolution.