logical and physical address in operating system,

2019-08-11 19:11发布

Why is the logical address needed?The CPU can directly produce the physical address for the different processes.

My second question is How is this logical address produced by CPU?

2条回答
等我变得足够好
2楼-- · 2019-08-11 19:43

Logical address is an address that is from the virtual memory. Its virtual because it actually does not exist.

Why is the logical address needed?

The answer is that normally programmers do not know what is the actual addresses of the main memory(the physical address) and besides the OS designers do expect every programmer to know what are the physical addresses. All the burden of translating these virtual addresses to actual physical addresses of RAM is the job of Memory Management Unit.

How is this logical address produced by CPU?

The CPU simply generates these addresses from the amount of virtual memory the particular process is allocated, which is usually a nice contiguous block, but the actual address being accessed need not be contiguous and address translation unit(page table,TLB,...) works under the hood to get the right actual physical addresses.

Here is a beautiful video that will definitely clear your doubts.

查看更多
别忘想泡老子
3楼-- · 2019-08-11 20:00

Logical address translation serves at least two functions. First, it is critical to system security. Page protection is implemented as part of logical memory translations.

Second, it aids in memory management. In particular, it would be impossible to implement virtual memory without logical memory translation.

I could add a third that might be considered part of the other two. Logical memory provides a means for sharing memory. For example, most operating systems define a range of logical addresses that serve as the "system space." These logical addresses map to the same physical addresses the same for all processes.

In larger applications, it is common for processes to share the same physical memory. That is done through logical address translation.

My second question is How is this logical address produced by CPU?

Logical addresses are not [generally] produced by the CPU. They are translated by the CPU into physical addresses using page tables. Operating systems set up the page tables that define the mapping from logical pages to physical page frame.s

查看更多
登录 后发表回答