In This Article
What is Dynamic Relocation?
Dynamic relocation refers to a process where the data stored in the memory of the computer is moved to other parts of it while the program is still active and creating a more efficient memory storage.
Technically, in this specific type of relocation process mapping from the virtual to the physical address space typically happens at runtime and is performed by a specific type of hardware device called the Memory Management Unit or MMU.
- Dynamic relocation is the process of moving the data stored in the memory to other parts during runtime.
- This relocation method allows generating a more efficient memory storage and its management.
- In this process virtual address space is mapped to physical address space by using the Memory Management Unit.
- The dynamic relocation process is quite safe, efficient, and a more advanced technique than static relocation.
- The process needs minimal hardware changes and simple, inexpensive registers to function.
Understanding Dynamic Relocation
In simple terms, dynamic relocation is the process of allocating new absolute addresses to the computer program in implementation.
It is an advanced method that involves the following:
- The relocation registers
- The Central Processing Unit (CPU)
- The hardware.
Ideally, the registers, hardware and the CPU, all work together to facilitate the working process during dynamic relocation performing their respective tasks as explained below.
Ideally, the logical register, which contains the smallest physical addresses, protects the user processes from the varying codes and data of the operation system and also from each other.
Also called the base register, it also helps the virtual address obtain the physical address.
Every address that is generated by the user process has the value in the relocation register added to them when these are sent to the memory.
Typically, in a dynamic relocation process, the operating system adds the value of the relocation register, which is generated by the compiler, and the register, in turn, makes the translation of the virtual address space into a physical address space.
The address is compared by the hardware with the limit address, which should be less than the base.
However, if it is not, then the CPU ignores the physical address by taking an address trap.
- It allows the operating system to move a process very easily when needed.
- It allows the process to grow over time since it can be relocated easily to a bigger memory block.
- It allows a more advanced way of relocating memory.
- It uses simple and inexpensive registers for the process.
- It needs minimal hardware changes.
- The process is quite efficient, transparent, and safe.
- It slows down the process due to additional operations.
- Sharing of memory is not allowed by the process.
- A fixed amount of physical memory is needed for it, which limits multiprogramming as every active process must fit into the memory.
- The process is complex, involving partitions, fragmentation, and others.
- The operating system has to overwork when the process grows.
- It does not allow sharing codes and data between processes.
Static Vs Dynamic Relocation
- The basic idea of dynamic relocation is to change the memory address dynamically, but in comparison, the same is done statically in the static relocation method.
- The process of dynamic relocation is much safer in comparison to static relocation.
- The dynamic relocation process is much more complicated in comparison to the static relocation process.
- The memory of one process cannot access another in dynamic relocation, but in comparison, it can happen in static relocation, which may even corrupt the memory of the operating system and others.
- The processes in a dynamic relocation can change size as opposed to the processes involved in a static relocation.
- The dynamic relocation process typically relocates memory during runtime. On the other hand, memory is allocated in the static relocation process at the compile time.
- The memory can be changed once the dynamic relocation process starts. On the other hand, it cannot be changed in the static relocation process.
- Usually, a dynamic relocation process is best suited for a linked list. On the other hand, the static relocation process is favored in an array.
- In dynamic relocation, memory is typically allotted from the heap. On the other hand, in the static relocation process, the memory is allocated from the stack.
- The dynamic relocation process is much more efficient in comparison to the static relocation process.
Which Registers are Used by Dynamic Relocation?
Dynamic relocation typically uses two specific registers, such as the simple addition register and the simple comparison register.
The process also uses a relocation register.
The dynamic relocation process is a safe and efficient method of memory management.
Though it is a bit complicated process, the fact that it allows changing memory addresses dynamically during the runtime using simple and inexpensive registers makes it quite a fast and favored method for the linked lists.