0
4.9kviews
Explain how logical address converted into physical address in paging and what is segmentation
1 Answer
0
166views

How logical address converted into physical address

An address generated by the CPU is commonly referred to as a logical address, whereas an address, is seen by the memory unit—that is, the one loaded into the memory address register of the memory—is commonly referred to as a physical address.

The compile-time and load-time address-binding methods generate identical logical and physical addresses. However, the execution-time address binding scheme results in differing logical and physical addresses. In this case, we usually refer to the logical address as a virtual address. We use the logical address and virtual address interchangeably in this text. The set of all logical addresses generated by a program is logical address space. The set of all physical addresses corresponding to these logical addresses is physical address space. Thus, in the execution-time address-binding scheme, the logical and physical address spaces differ.

The run-time mapping from virtual to physical addresses is done by a hardware device called the memory-management unit (MMU). For the time being, we illustrate this mapping with a simple MMU scheme that is a generalization of the base-register scheme. The base register is now called a relocation register.

Only when it is used as a memory address (in an indirect load or store, perhaps) is it relocated relative to the base register. The user program deals with logical addresses. The memory-mapping hardware converts logical addresses into physical addresses. The final location of a referenced memory address is not determined until the reference is made.

We now have two different types of addresses: logical addresses (in the range 0 to max) and physical addresses (in the range R + 0 to R + max for a base value R). The user program generates only logical addresses and thinks that the process runs in locations 0 to max. However, these logical addresses must be mapped to physical addresses before they are used. The concept of a logical address space that is bound to separate physical address space is central to proper memory management.

Segmentation

  • Segmentation is a memory-management scheme that supports this programmer's view of memory. A logical address space is a collection
    of segments.

  • Each segment has a name and a length. The addresses specify both the segment name and the offset within the segment.

    enter image description here

  • The programmer, therefore, specifies each address by two quantities: a segment name and an offset. For simplicity of implementation, segments are numbered and are referred to by a segment number, rather than by a segment name.

  • Thus, a logical address consists of two tuples: <segment-number, offset>. Normally, when a program is compiled, the compiler automatically constructs segments reflecting the input program.

A-C compiler might create separate segments for the following:

  • The code

  • Global variables

  • The heap, from which memory is allocated

  • The stacks used by each thread

  • The standard C library

    Libraries that are linked in during compile time might be assigned separate segments. The loader would take all these segments and assign them segment numbers.

Please log in to add an answer.