This preview shows page 1. Sign up to view the full content.
Unformatted text preview: . You will learn how to manage virtual memory via explicit memory mapping and calls to dynamic storage allocators such as the malloc package. You will also learn about a host of common memory-related errors in C programs and how to avoid them. 10.1 Physical and Virtual Addressing
The main memory of a computer system is organized as an array of Å contiguous byte-sized cells. Each byte has a unique physical address (PA). The ﬁrst byte has an address of 0, the next byte an address of 1, the next byte an address of 2, and so on. Given this simple organization, the most natural way for a CPU to access memory would be to use physical addresses. We call this approach physical addressing. Figure 10.1 shows an example of physical addressing in the context of a load instruction that reads the word starting at physical address 4.
Main memory 0: 1: 2: 3: 4: 5: 6: 7: 8: CPU Physical address (PA) 4 ... M -1: Data word Figure 10.1: A system that uses physical addressing. When the CPU executes the load instruction, it generates an effective physical address and passes it to main memory over the memory bus. The main memory fetches the four-byte wor...
View Full Document