in Operating System edited by
337 views
0 votes
0 votes
Difference between logical address and physical address.

M getting so confused between this two. Sometimes it is mentioned that logical address is what viewd by the user as user can't view physical address but then it is given it is generated by the CPU.

Explain in simple language not bookies words. Thanks.
in Operating System edited by
337 views

1 Answer

0 votes
0 votes

First things first:

To be very honest, when we say "users" we don't mean you and I in this context.

A process in running state is using the CPU and it is the process which generates the addresses.

What is a logical address? Each process knows only about its own existence (at least by the code of conduct of good processes). Let's consider a hypothetical case:
Say a process has exactly 100 lines of instruction. It will generate addresses (while running) 0 to 99. These are logical addresses and the process knows only about these.

But in the memory (a.k.a. RAM) actual 0 through 99 is usually taken up by OS so the loader will try to put it somewhere, say, 2240 through 2339. These addresses are not known/visible to the process. Now at runtime the MMU will perform the mapping of say logical address 1 to physical address 2241.


Logical Adress space is a concept related to virtual memory. Say, a process generates 1000 addresses, but it can be provided only 100 locations, then the process will be brought into memory in installments. But, the process will never know about this cheating. It will innocently believe it has all the 1000 locations; because it sees only logical addresses :)

Note: the answer has been edited. The loader is resident in memory as part of the kernel.
         Memory Management Unit is set of hardware components that perform Logical Address to Physical Address mapping for run time binding.
 

Hope this was useful.

edited by
by

4 Comments

What MMU actually do?
1
1
edited by
Good point, edited answer. Please let me know if something still wrong.
0
0
All the addressee generated by process(logical address) is actually differently stored in physical location (main memory/virtual memory-physical address) and to give right direction to process logical address it is converted to virtual addresses which is done by MMU.

Correct me if I wrong . Do let me know if I understood it right.
0
0
Sorry I made couple of mistakes on this one.

Logical to physical.

Logical address(LA) and Virtual Address(VA) are synonymous.

The point is, it can't be predicted what physical address range a process will get at runtime, because based on conditions at that time, the process may be loaded anywhere in RAM.

Process will generate addresses counting from 0. These are not directly related to the RAM.

The MMU will map these logical addresses to the actual physical address.

Virtual memory is a concept; it is the apparent space available to a process. Made up of RAM and swap space of the HDD.
0
0

Related questions