Talk:Overlay (programming)
About that merge
I reverted the changes to this article, but I left standing the change of Overlays to a redirect, and I'm about to remove the mergefrom tag from here. There was really nothing in the other article worth saving and a fair share of what it had to say was misleading. Atlant 17:21, 13 July 2006 (UTC)
- I thought my merge was cleaner. Why not restore the many wiki links that you reverted? Which is clearer:
- Mine: This operation is similar to virtual memory, but is not fully automatic or transparent to the programmer in the same way; instead, the overlay strategy...
- Revert: This operation is similar to virtual memory, but is not usually not fully-automatic or transparent to the programmer; instead, the overlay strategy...
- Shouldn't this be a compsci stub like I had it? I think you may want to go back and pick and choose the reverts you're not happy with, it is not all junk. — RevRagnarok Talk Contrib Reverts 17:37, 13 July 2006 (UTC)
- The biggest problem with your merge was the overall tone. It immediately dove into the multi-pass compiler stuff, and that's only a small corner of the much larger world of overlays and what they're used for. I'd be happy to do another edit of this article, comparing your diffs, but I haven't got the time right now, and the revised article was just too far off base. Maybe this evening...
Physical? Or virtual?
I'm a new wikipedian so please don't be too harsh if I'm breaking some rules. I did my homework reading through the help pages but still...
I'd like to change the article referring to Overlays because, in my opinion, the association with Virtual Memory concept is not appropriate. More, the "virtual address space" in the first sentence is wrong. It should be quite the opposite, physical memory, that I would accept.
Virtual address space is an abstract concept representing the collection of memory locations in a system with a certain number of address lines. For example, the virtual address space of a CPU with 16-bit address bus is 64K (65536) locations.
I'm open to discussions, but I think this is a better definition of Overlays.
--- Overlaying is a programming method that allows programs to be larger than the CPU's main program memory (or whatever block of memory the CPU is supposed to draw its instruction from, in case not all main memory is available at a certain moment, or not all memory is available for that program).
This method assumes dividing a program into self-contained machine code object blocks (called "overlays") not bigger than the maximum block of available program memory. The overlays are supposed to be loaded (from external memory or support where the program resides) into the CPUs main memory in order to be executed.
Embedded systems would normally use overlays because of the limitation of physical memory (internal memory for systems-on-chip). ---
Adsp 12:56, 18 January 2007 (UTC)
- I'm sorry, but if you insist on "physical memory", you would be wrong. Overlays were widely used in systems that had, say, 16-bit virtual address spaces but had larger physical address spaces (for example, 22-bits). What such overlays allowed was the running of programs larger than 64K. For example, using overlays, I personally wrote a program that was about 1.5 Meg in size and still "fit" within the 64K virtual address space of a PDP-11.
- Where it gets confusing is that overlays are not necessarily swapped to and from the backing storage (e.g., disk). Systems that have large amounts of physical memory will often store many or all of the overlays in physical memory, swapping them in and out of the virtual address space as needed. This process (of exchanging virtual->physical address mappings) is obviously orders of magnitude faster than swapping information to/from the disk and in such a system, you could change overlays tens or hundreds of times per second with very little performance penalty.
- Be careful that you're not confusing virtual memory with virtual address space.
Yes, I'm afraid I have to insist.
What is the difference between virtual memory and virtual address space, then? Oh, if you mean virtual memory is a technique also known as virtual memory addressing of a contiguous space known as virtual address space, then yes, they are different. But the key concept here is virtual. And you use virtual as physical. It is physical because it does exist.
What you describe in your 16-bit / 22-bit example is more like paging. And what you call physical space in that example is actually external memory and you will use an I/O operation to select the page, which actually means that the external memory is more like a peripheral. It's external anyway, as opposed to main memory, what you actually call virtual memory (which is not virtual at all since the processor can fetch code from that memory).
I don't have a problem with memory overlays (but I want to stress external memory), it doesn't matter where they are stored (yes, it might be faster loading from external memory than from disk). But the essential idea is that they are loaded in CPU's main memory, which is physical, no doubt.
I'm not sure when the concept of virtual memory came around, but I suspect it was after the PDP-11 episode of paging (and by the way, I have done that too, on some advanced Spectrum with more than 64K memory, I don't remember what the name was). And I suspect that virtual memory was associated with CPUs that had plenty of address lines (like 32-bit machines) but memory was expensive enough to prevent physical population of the whole space (and still is, only supercomputers have 4 GB main memory, I think).
In conclusion, overlays are not so much about virtual and physical memory, it's about main memory, the overlay has to be loaded into CPUs main memory in order to be executed.
--Adsp 19:41, 18 January 2007 (UTC)
- No, and your confusion between the concepts of virtual memory and virtual address space really suggests that you need to learn more about all of this before you start editing this article. So let's get definitional:
- The virtual address space is that set of addresses that the machine can simultaneously specify using its various addressing modes (and without manipulating any memory-mapping hardware). For simple machines that have a Von Neuman architecture, that's usually a single space of about the same size as the width of the registers, so 16 bits on the PDP-11, 32 bits on a VAX, Power(PC), or SPARC, and 64 bits on Alphas, UltraSPARCs, and the latest POWER chips. For Harvard architecture machines, there can be multiple virtual address spaces, for example, one for code, one for data, and on more baroque architectures such as the 8051, a few more thrown in just for confusion.
- The physical address space is that set of addresses that can be passed to the memory system and responded to.
- Virtual memory is memory that can be accessed by the processor but is not necessarily all physically present in physical memory at all times. It doesn't matter how big the virtual address space is compared to the physical address space although most interesting cases are machines that have virtual address spaces bigger (sometimes, much bigger) than the physical address space. Generally speaking, the magic that happens behind the scene to make all virtual accesses succeed (page faulting and the like) is all completely transparent to the user's program.
Overlays are a completely orthogonal concept. They are a way to manipulate memory that replaces portions of the virtual address space so that machines with a limited virtual address space can run humongous programs too. Generally speaking, overlays only turn upon machines with small virtual address spaces (such as the PDP-11 or PDP-8).