Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

Dynamic loading vs. dynamic linking

Muhammad Ahmad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

Before actually drawing the difference between dynamic loading and dynamic linking, it's imperative to understand the loading and linking in the operating system first.

These essential utility programs play a vital role in the program's execution.

Loading

The process of getting a program from secondary storage (hard disk) to the main memory (RAM) is known as loading. In simple words, loading loads the program in the main memory.

Linking

Linking all the required modules of the program to continue the program execution is known as linking. It intakes the object code through an assembler and combines them to make an executable module.

Let's have a look at the figure below to understand it better.

Working of loading and linking

The linking and loading are further categorized into the two following types:

  1. Static
  2. Dynamic

As our answer is about dynamic linking and loading, we'll discuss that. The dynamic linking or loading utilizes the memory very efficiently.

Dynamic loading

Before actual execution, all the programs are loaded into memory first. Sometimes the whole program is loaded into the memory, but sometimes a small part of the program or some routine is loaded into memory only. This mechanism of loading the program variably is known as dynamic loading.

Note: A dynamic load is any load of the program that changes over time or over the need. And it's done during the runtime or execution time.

Dynamic linking

Linking the object modules and dependent libraries during execution is known as dynamic linking. If the program call happens before execution time, it is postponed until execution.

Note: In dynamic linking, the code for some external routines is located and loaded when the program is first to run.

Dynamic loading vs. Dynamic linking

Dynamic loading

Dynamic linking

The process of loading a system library or a system routine at runtime.

The process that links dependent libraries or routines at runtime.

It is not supported by OS.

It is supported by OS.

It refers to mapping an executable or library into a process's memory after it has started.

It refers to resolving symbols—associating their names with addresses or offsets—after compile time.

  • The object module is loaded dynamically under the program control (after start).
  • Symbols in the calling program and the library are resolved based on the process's possibly-unique memory layout.

RELATED TAGS

CONTRIBUTOR

Muhammad Ahmad
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring