I read that , "When a program executes an instruction like : MOV REG,1000
, it does so to copy the contents of the memory address 1000 to REG. Address can be generated using indexing,base registers,segment registers and other ways.
These program generated address are called virtual address and form the virtual address space."
Can anyone please explain me,what does it (These program generated address are called virtual address) mean ?
Programs and data are stored as numbers in memory cells. Each memory cell has a unique number, called its address. The range of numbers representing valid addresses is called address space.
When programs run, the CPU reads data from memory and writes results back to memory. CPU communicates the desired location to the memory by specifying the address of the memory cell targeted by a read or a write operation.
There are multiple ways in which the CPU can come up with an address (remember, address is only a number). The number representing the address could be in a register, it could be stored at another memory location, it could be calculated by adding or subtracting an offset to a register, and so on. In all cases your compiled program instructs CPU on how to come up with (or generate) the address it needs to read or write.
Modern architectures let multiple programs execute as if they own the entire logical address space. In other words, several programs could write to memory location at the same address without stepping over each others' results. This is done by virtualizing the address space: let's say programs A and B generate a write to memory location at 0x1000. The CPU, aided by the operating system, could performs additional adjustments to the address, and map it to physical address 0x60001000 for program A, and to 0x5F001000 for program B. Both programs think that they wrote to the location at 0x1000, because they operate in a virtual address space. Their model of the memory is a contiguous block starting at 0 and continuing to 0x000100000000 (assuming that your system has 4GiB of memory available to processes). But this model works only because the CPU additionally translates their logical addresses to physical addresses, which are allocated and taken away as needed in the process of running the program.
Because the same number representing an address means different things to a program and to a CPU, the address space of the program is called virtual, and the address space of the CPU is called physical.
When a program accesses memory, it does not know or care where the physical memory backing the address is stored. It knows it is up to the operating system and hardware to work together to map locate the right physical address and thus provide access to the data it wants. Thus we term the address a program is using to access memory a virtual address. A virtual address consists of two parts; the page and an offset into that page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With