Understanding the virtual address and virtual address space

I read that: "When a program executes a command like: MOV REG,1000 , it does this to copy the contents of memory address 1000 to REG. The address can be generated using indexing, base registers, segment registers, and other ways.

This address generated by the program is called a virtual address and forms a virtual address space.

Can someone please explain to me what this is (this program-generated address is called a virtual address)?

+8
architecture virtual operating-system memory-address virtual-address-space
source share
2 answers

Programs and data are stored as numbers in memory cells. Each memory cell has a unique number called its address. A range of numbers representing valid addresses is called an address space.

When programs start, the CPU reads data from memory and writes the results back to memory. The CPU associates the desired location with the memory, indicating the address of the memory location indicated by the read or write operation.

There are several ways a processor can get an address (remember, an address is just a number). The number representing the address may be in a register, it may be stored in another memory location, it may be calculated by adding or subtracting an offset into the register, etc. In all cases, your compiled program instructs the CPU on how to come up with (or generate) an address that it should read or write.

Modern architectures allow you to run several programs as if they own the entire logical address space. In other words, several programs can write to a memory location at the same address without stepping over each other's results. This is done by virtualizing the address space: let programs A and B generate an entry in the memory cell at 0x1000. The CPU controlled by the operating system can make additional address settings and map it to the physical address 0x60001000 for program A and 0x5F001000 for program B. Both programs believe that they wrote the location in 0x1000, since they work in a virtual address space. Their memory model is a continuous block starting at 0 and continuing up to 0x000100000000 (assuming your system has 4GiB of memory available for processes). But this model only works because the CPU additionally translates its logical addresses to physical addresses, which are allocated and selected as necessary during the program launch.

Since the same number representing the address means different things for the program and for the CPU, the address space of the program is called virtual, and the address space of the CPU is called physical.

+27
source share

When a program accesses memory, it does not know or care about where the physical memory supporting the address is stored. He knows that the operating system and hardware work together to display the correct physical address and thus provide access to the required data. Thus, we call the address that the program uses to access the virtual address. The virtual address consists of two parts; page and offset to this page.

+1
source share

All Articles