4th Week: CST 334

 

Topic: Memory Virtualization

Hello everyone,

    In this week’s material we covered the idea of memory virtualization in detail like the ideas of free space management, paging, translations, page tables, swapping mechanism and swapping polices. One important thing I learned was understanding how memory is allocated dynamically using APIs for example malloc. This allows programs to allocate memory from the heap. The goals of memory allocators are to balance accuracy, speed, and efficiency while managing memory effectively.

    But dynamic memory allocation causes an issue known as external fragmentation. This happens when free memory is divided into small, noncontiguous blocks that are too small to use effectively. A solution to the problem of external fragmentation is paging, which eliminates the issue by dividing virtual memory into fixed-sized units called pages. These pages are mapped to physical memory, which is divided into page frames, and a page table is used to translate virtual addresses to physical addresses.

    Paging gives advantages such as flexibility because it eliminates the requirement for address spaces to be contiguous and avoids external fragmentation. Also, paging simplifies free space management by allocating memory in fixed size chunks, pages, and maintaining a free list. However, one drawback of this technique is that it may cause internal fragmentation where pages are only partially filled leading to unused memory within each page.

    We also looked into making the page table translations faster, using Translation Lookaside Buffer (TLB), a cache that stores virtual address (VA) to physical address (PA) mappings. When translating a VA to a PA, the Memory Management Unit (MMU) first checks the TLB. A TLB hit is a hit if is found in the cache, the MMU retrieves the PA directly from the TLB, saving the overhead of accessing the page table in main memory. But on a TLB miss, the MMU must do a page table lookup and if the page is not found in memory, then it is considered a page fault. A page fault requires the operating system to load the page into main memory from secondary storage which is expensive. This process involves page swapping from disk. When a page fault occurs, the operating system sets a trap, causing the CPU to switch to kernel mode to handle the disk fetching process. A lot of information!

Comments

Popular posts from this blog

CST438 Software Engineering: Week 8 (Final week)

CST438 Software Engineering: Week 1

CST370 Week 5