What is Relocation in Operating System?
In this Study Material for Gate Computer Science today we are going to tell about the relocation concept in Operating System. Here in this post today we will learn what is relocation ? different types of relocation like static relocation and dynamic relocation. Let’s start with the definition of relocation.
Most of the time we hear the word program relocatability in memory management. what does it mean ? The term program relocatability refers to the ability to load and execute a given program into memory. In reality, the program may be loaded at different memory locations, which are called physical addresses
When a process is loaded in main memory, since there are several instructions inside the process so here address of these different instructions inside the process are relocatable addresses. which are converted into actual addresses by the loader by the loader in software approach. But there is some problem with this approach suppose if a process is first loaded then remove and then after loaded again so in this situation loader will get confused.
 So to avoid this problem operating system use another method for relocation. Instead of using this load time binding operating system used runtime binding. Here runtime binding means it leaves these relocatable addresses as it is it does not convert these relocatable addresses into absolute addresses but when CPU generate any logical or virtual address then this logical address you can be considered this logical address as the relocatble address which is going to map its corresponding physical address by memory management unit.
Types of Relocation in Operating System
Generally, there are two types of relocation
   Static Relocation
What happens exactly in this approach is that here operating system manages the memory address of a process to reflect its starting position in the memory. Once a process is assigned a starting address in memory it executes within the space it has been allocated. Once static relocation process has been completed operating system can no longer further relocate process until its terminate. Â
The value in the relocation register is added to every address generated by a user process at the time the address is sent to memory (see Figure 4). For example, if the base(relocation register content) Â is at 14000, then an attempt by the user to address location 0 is dynamically relocated to location 14000 and an access to location 346 is mapped to location 14346.
I hope this gate study material for computer science will be beneficial for computer science students.