Posts

Showing posts with the label virtual

16.2.7 Worked Examples Virtual Memory

Virtual memory allows programs to behave as if they have a larger memory than they actually do. The way this works is by using virtual addresses, which refer to addresses on disk, in our programs. The virtual addresses are translated into physical addresses using the page map which is a lookup table that has one entry per virtual page. The page map knows whether the virtual page is in physical memory and if so it immediately returns the physical page number. If the page is not in physical memory, then this causes a fault which means that the virtual page must be brought in from disk to physical memory before it can be accessed. To do this the least recently used (LRU) page in the physical memory is removed to make room for the address that is currently being requested. The page map is also updated with the new mapping of virtual to physical pages. Since bringing data to and from disk is an expensive operation, data is moved in chunks. This makes sense because of the conce...

16.2.2 Basics of Virtual Memory

Here's how our virtual memory system will work. The memory addresses generated by the CPU are called virtual addresses to distinguish them from the physical addresses used by main memory. In between the CPU and main memory there's a new piece of hardware called the memory management unit (MMU). The MMU's job is to translate virtual addresses to physical addresses. "But wait!" you say. "Doesn't the cache go between the CPU and main memory?" You're right and at the end of this lecture we'll talk about how to use both an MMU and a cache. But for now, let's assume there's only an MMU and no cache. The MMU hardware translates virtual addresses to physical addresses using a simple table lookup. This table is called the page map or page table. Conceptually, the MMU uses the virtual address as index to select an entry in the table, which tells us the corresponding physical address. The table allows a particular virtual address t...