![]() In a (modern) multitasking computer, which can run many programs at once, and features memory protection, each program is usually seperated from other programs running on the same system. Now, where it gets more complicated is that, modern systems feature memory mapping and memory protection, which is all usually handled by the same hardware system in the computer: the memory management unit, or MMU. ![]() All of the pages of information don't fit in memory, so some pages are put on disk, and loaded again later. Different systems have different names for these things, but the general concept is much the same. On linux and unix, the place where these pages are stored is literally called a "pagefile", and the pages of data in memory are literally called "pages". This is like the computer "paging" its memory - writing pages full of information, and putting it into "virtual memory" for later reference, and realising it needs a page, and loading that page back from virtual memory into real memory. We might not be able to remember a huge list of sales figures for the month, but we can look at the pages, get the information a bit at a time, and process each bit. We note down on pages all the things we can't remember at once, but refer to them while doing the sums. ![]() You get confused, start to slow down, fail to keep it all in there at once, and have to forget something to remember something else. However, when you're learning complex information, or working with complex sums, you might not be able to fit all that in your head at once. This is like a computer loading files from the hard drive - it loads up the programs or pictures or other information it needs to work into its "real memory" (or "physical memory") and works on them with it's "brain" (its processor). When you're working out simple sums, or learning simple information, you do it all in your head: you just load up all the information, process it, and get the answer. As the name suggests, paging is like a human notepad. Virtual memory, as commonly used, refers to "paging". I'll try to start slowly, and then put this all together for you. If you tell the device to write 8K of data to the physical address corresponding to the start of that array, it will write the first 4K where you expect, but the second 4K will corrupt some memory somewhere. An 8K array might be virtually contiguous (through the MMU) but two physically separate pages. Any large (multi page) blocks of memory you send are physically contiguous.Any raw memory addresses you pass to the hardware are physical, not virtual.So as a driver writer you need to ensure: The device probably does not go through the MMU, so it sees raw physical addresses. Your driver code runs on the CPU, which means its memory accesses are through the MMU (virtual). Your textbook defines virtual memory (incorrectly) as just #3.Įven without any swapping, you particularly need to be aware of virtual memory if you write a device driver for a device which does DMA (direct memory access). Memory at a virtual address can be "paged out" to disk, and then "paged in" when it is accessed again.Memory at a given virtual address may not be located at the same physical address.A process can not see memory in other processes (unless the OS wants it to!).The mapping from virtual addresses to physical addresses is handled by a memory management unit, which is managed by the operating system. A process might see an address space of 4GB, which it has entirely to itself. The computer has, say, 2GB of physical RAM, addressed from 0 to 2G. Virtual memory is a layer of abstraction provided to each process. Note that "virtual memory" is more than just "using disk space to extend physical memory size"
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |