Whats the difference between a virtual and physical address

What\'s the difference between a virtual and physical address? Where would each kind of address (VA, PA) be used? (programs, pieces of hardware, etc) What is the maximum number of pages a process can have? When we say that a virtual address generates a page fault, what do we really mean? What is the solution to this problem?

Solution

Virtual vs Physical Addresses Physical addresses refer to hardware addresses of physical memory. Virtual addresses refer to the virtual store viewed by the process. • virtual addresses might be the same as physical addresses

• might be different, in which case virtual addresses must be mapped into physical addresses. Mapping is done by Memory Management Unit (MMU).

• virtual space is limited by size of virtual addresses (not physical addresses)

• virtual space and physical memory space are independent How can it work if a 32-bit virtual address allows 4GB of space to be addressible for a single process and multiple processes run on machines with less than this amount of physical memory? 1. processes don’t use all of the 4GB of space. 2. only a portion of the address space that processes do use is loaded into physical memory at a time.

Are you talking about memory addresses and virtual memory?

In that case.

The physical memory is the primary memory (RAM). A physical address is the address to a physical memory location in the primary memory.

The secondary memory is normally a disk, like a swap partition or a swap file, and (normally) much slower than the primary memory.

The virtual memory is the physical memory combined with the secondary memory. A virtual address is the address of something stored in the virtual memory. The data stored at a virtual address might be located in the primary or in the secondary memory.

A programmer uses the virtual address when addressing data. To the programmer it appears as if there is a large amount of fast physical memory available and he/she never has to worry about that the program might need more physical memory than available.

The instructions being executed and the data that is read/written must be in the primary memory. The programmer don\'t have to worry about this either, the system takes care of that. If the page containing the requested virtual address is not in the primary memory, the operating system finds some free physical memory (or selects a page to swap out to secondary memory) and loads the requested page to the primary memory.

Physical addressing means that your program actually knows the real layout of RAM. When you access a variable at address 0x8746b3, that\'s where it\'s really stored in the physical RAM chips.

With virtual addressing, all application memory accesses go to a page table, which then maps from the virtual to the physical address. So every application has its own \"private\" address space, and no program can read or write to another program\'s memory. This is called segmentation.

Virtual addressing has many benefits. It protects programs from crashing each other through poor pointer manipulation, etc. Because each program has its own distinct virtual memory set, no program can read another\'s data - this is both a safety and a security plus. Virtual memory also enables paging, where a program\'s physical RAM may be stored on a disk (or, now, slower flash) when not in use, then called back when an application attempts to access the page. Also, since only one program may be resident at a particular physical page, in a physical paging system, either a) all programs must be compiled to load at different memory addresses or b) every program must use Position-Independent Code, or c) some sets of programs cannot run simultaneously.

The physical-virtual mapping may be done in software (with hardware support for memory traps) or in pure hardware. Sometimes even the page tables themselves are on a special set of hardware memory. I don\'t know off the top of my head which embedded system does what, but every desktop has a hardware TLB (Translation Lookaside Buffer, basically a cache for the virtual-physical mappings) and some now have advanced Memory Mapping Units that help with virtual machines and the like.

The only downsides of virtual memory are added complexity in the hardware implementation and slower performance.

Maximum no of pages for a process can have:-

The answer would depend on exactly how memory is managed on a particular operating system, and so the question needs more details to be answerable. In many cases a rough approximation would be:

Max pages per process = Max memory available to a process / Size of a page

Max memory available to a process = Total memory (incl. additional memory from swap file) - Memory reserved for OS use

 What\'s the difference between a virtual and physical address? Where would each kind of address (VA, PA) be used? (programs, pieces of hardware, etc) What is t
 What\'s the difference between a virtual and physical address? Where would each kind of address (VA, PA) be used? (programs, pieces of hardware, etc) What is t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site