Open In App

Difference between Loading and Linking in Operating System

An operating system acts as an intermediary between the user of a computer and computer hardware. The purpose of an operating system is to provide an environment in which a user can execute programs conveniently and efficiently.

Linking and Loading are utility programs that play an important role in the execution of a program. Linking intakes the object codes generated by the assembler and combines them to generate the executable module. On the other hand, the loading loads this executable module to the main memory for execution. 



What is Loading?

To bring the program from secondary memory to main memory is called Loading. It is performed by a loader.  It is a special program that takes the input of executable files from the linker, loads it to the main memory, and prepares this code for execution by a computer. There are two types of loading in the operating system:

What is Linking?

Establishing the linking between all the modules or all the functions of the program in order to continue the program execution is called linking. Linking is a process of collecting and maintaining pieces of code and data into a single file. Linker also links a particular module into the system library. It takes object modules from the assembler as input and forms an executable file as output for the loader. Linking is performed at both compile time when the source code is translated into machine code, and load time, when the program is loaded into memory by the loader. Linking is performed at the last step in compiling a program.



For more information please refer to the Static and Dynamic Linking in Operating Systems article.

 

Differences between Linking and Loading

Linking

Loading

The process of collecting and maintaining pieces of code and data into a single file is known as Linking in the operating system. Loading is the process of loading the program from secondary memory to the main memory for execution.
Linking is used to join all the modules. Loading is used to allocate the address to all executable files and this task is done by the loader.
Linking is performed with the help of Linker. In an operating system, Linker is a program that helps to link object modules of a program into a single object file. It is also called a link editor. A loader is a program that places programs into memory and prepares them for execution.
Linkers are an important part of the software development process because they enable separate compilation. Apart from that organizing a large application as one monolithic source file, we can decompose it into smaller, more
manageable modules that can be modified and compiled separately.
The loader is responsible for the allocation, linking, relocation, and loading of the operating system.
Article Tags :