The Wayback Machine - https://web.archive.org/web/20230816065641/https://www.geeksforgeeks.org/static-and-dynamic-loader-in-operating-system/
Skip to content
Related Articles
Open In App
Related Articles

Static and Dynamic Loader in Operating System

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Prerequisites: Basic Functions of Loader

An Operating system is the critical component for managing the various memory resources in the computer system. One of the essential task of the operating system is to manage the executable programs or applications in the computer system. A program need to be loaded into the memory for the purpose of execution. For the execution context, loader comes into the picture.

What is Loader?

A loader is module which is the essential part of the operating system, that is responsible for loading the program from secondary memory to main memory and execute them. 

  • The main function of leader is to locate the executable file inside the file system.
  • Loader allocates memory to store the program and once the memory is allocated then it loads the program in that memory space.
  • Loader is also responsible to resolve the external dependencies such as references, system libraries mentioned inside the program.
  • Loaders are responsible for ensuring the correct loading of program inside the memory.
  • There are two types of loading in operating system, Static and Dynamic Loading.

Static Loader

The static loader is a program that loads the entire executable program including, libraries and dependencies required by the program into the memory before the program gets executed.

  • After loading the program into the memory, the loader resolves all the external dependencies in the program, this process is known as static linking.
  • Once the linking is done, the loader updates the address of the program.
  • No additional software is needed for loading and linking the entire program. 
  • Static linking is applied for the static loader.
  • Static loader is portable as it can work in any platform which supports the executable format used by the program.

Advantages of Static Loader

  • Static loaded is easy and simple to implement.
  • As the entire program is loaded into the memory once, this makes the static loaded very much faster.
  • Static loaded is reliable because it resolves all the external references before the execution of the program.

Disadvantages of Static Loader

  • The main disadvantage of static loaded is wastage of memory because its load all the data and code into memory before execution. 
  • Static loader is not flexible as it does not handles the dynamic loading of the data.
  • Static loader is not efficient as the data or code that it loads, it may or may not be executed after.
  • Static loader is inflexible because it does not adapt the changes in the program’s requirement at dynamic environment.

Applications of Static Loader

  • Standalone Executables : Static loaders are used to create the standalone executables in software applications.
  • High-Performance Applications : Static loader is used for the high performance application for its fastness.

Dynamic Loader

While executing a process, the entire program and the required process data should be present in the physical memory which in terms limits the process size with the size of physical memory. For proper utilization of physical memory, dynamic loader comes in picture.

  • The dynamic loader is a program that loads the program into the main memory on demand. 
  • Dynamic loader loads only the required code an data by the program and leaves the rest part in the executable file.
  • Dynamic loader resolves all the external dependencies and the entire process is known as dynamic linking.
  • Dynamic loader is very useful when a large amount of data need to handled in the efficient manner.

Advantages of Dynamic Loader

  • Dynamic loader is very much memory efficient as it loads only the necessary data and code for the execution.
  • Dynamic loader is very much flexible because it can adapt the changes in the program’s requirement at dynamic environment.
  • Dynamic loader can reduce the executable file size by excluding the libraries and dependencies from the binary.

Disadvantages of Dynamic Loader

  • Dynamic loader is more complex and it is difficult to implement.
  • Dynamic loader is having high overhead as it resolves all the external dependencies at run time.
  • Dynamic loader takes longer time to load the program in the memory.
  • Dynamic loader is portable as it is not platform independent. It may not work in all the platform because of dynamic linking mechanism.
  • Dynamic loader is less reliable because it resolves the external dependencies in runtime which may sometimes lead to error.

Applications of Dynamic Loader

  • Memory Efficiency : Dynamic loading is useful in memory efficient applications where usage of memory is a serious concern as the dynamic loader loads only the necessary part of the program thus it is memory efficient.
  • Plugins and Extensions : Dynamic loader is used to load the plugin and extensions into the application at run time.

Performance Comparison of Static and Dynamic loader

CategorySattic LoaderDynamic Loader
MemoryHighLow
FlexibilityLowHigh
EfficiencyHighLow
ReliabilityHighLow
ImplementationEasyComplex
Loading TimeFastSlow
External ReferencesResolved beforeResolved at the runtime

Difference between Static and Dynamic Loader 

Static Loader

Dynamic Loader

Static loader loads the entire program into the memory before the execution starts.Dynamic loader loads only the necessary part of the program for execution.
It does not need any runtime linking.It needs runtime linking.
It is used incase of static loader.Dynamic linking is used incase of dynamic loader.
This is faster as no files are changes during the execution.It is slower as the files as the files are uploaded at the run time.
Static loader makes memory wastage.Dynamic memory is memory efficient.
It is suitable for high performance applications.This is suitable for resource constraint applications.
It eliminates the runtime errors It can create runtime error if the required dependency is not available.
Static loader is used for compiler languages.It is used for interpreted languages.
It is less flexible as it loads the entire program in the memory.It is more flexible.
It is more predictable as the entire program and dependencies are loaded in the memory once.It is less predictable than static loader.
Static loader requires more disk space.Dynamic loader requires less disk space.

Conclusion

In this article we have mentioned several advantages and disadvantages of the static and the dynamic loader. For more details you can refer Difference between Loading and Linking in Operating System and Difference between Static and Dynamic Loading


Last Updated : 15 May, 2023
Like Article
Save Article
Similar Reads