Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between linear ,physical ,logical and virtual memory address?

I am trying to read Intel software developer manual to gain some understanding how operating system works and these four addressing terms is confusing me . Here is what i have understood, correct me if I am wrong.

linear address : What appear to a isolated program a long string of memory which start with address 0. all the segment of that program will be addressed from its linear address. It may be in the ram or in the disk.

physical address : Address that appear in the ram or main memory pins .

logical address : Combination of swap memory in the disk and ram . All the linear memory for all the program will stay in logical address space.It can be only used by kernel mode. The translation from logical to physical address is done by internal hardware.

virtual address : Virtual address is same as linear address. It will be only used by user mode in the operating system. Operating system will map virtual address from logical address.

like image 525
NomanMahdi2424 Avatar asked Jan 25 '23 21:01

NomanMahdi2424


1 Answers

The linear address space denotes all addresses that can be formed on the system. An address for any byte in linear address space is called a linear address. Todays system have around 46 bits of memory bus width, which corresponds to a linear address space of around 64 TiB. Intel only uses this term in its flat memory model.

The memory that the processor addresses on its bus is called physical memory. Each byte is assigned a unique address, called a physical address. It should be noted that in addition to the memory, memory-mapped I/O devices are also connected to this bus and can be addressed. This memory area also does not have to be contiguous, the memory controller here assigns the physical addresses to individual memory bars and devices.

Paging now adds virtual address spaces: each program is assigned its own linear address space. Some addresses in this address space are valid, others are not. valid addresses refer to data that may be in the physical memory but also to outsourced data on a hard disk (swap files). The translation is done in hardware by the MMU (Memory Management Unit) together with the TLB (Translation Lookup Buffer) or by the operating system. It is also possible that this data does not exist at all and is only generated when accessed, but this leads too far here. Let us note that these are the virtual addresses.

Logical addresses are a term that intel uses in the segmented memory model: there the memory is divided into segments. To address a byte in a segment, a logical address is used. This consists of a segment selector and an offset. Logical addresses are converted into virtual addresses using the segment selectors: The selector contains the beginning of the segment and its size. If the offset is larger than the size of the segment, the address is invalid. Adding the beginning of the segment to the offset gives you the virtual address. This segmented memory model was largely abolished in 64bit mode.

Summary

Logical Addresses -> Virtual Addresses -> Physikal Addresses

Virtual addresses and physical addresses are linear addresses, but not the other way around.


References:

  • Intel 64 and IA-32 Architectures Software Developer's Manual - Volume 1 Basic Architecture
    • 3.3.1 IA-32 Memory Models
    • 3.3.2 Paging and Virtual Memory
like image 145
fcdt Avatar answered Jan 29 '23 13:01

fcdt