1
$\begingroup$

First of all, I saw many answers of this topic in Quora, Stackoverflow, and this site. But, I couldn't definitely understand the difference between dynamic loading and dynamic linking.

What I understood until now is this.

Dynamic loading : system library or other routine is loaded during run-time and it is not supported by OS.

Dynamic linking : system library or other routine is linked during run-time and it is supported by OS.

What I'm confusing is the behaviour of this two concepts. I know that loading occurs after linking like below image. (from Operating System concepts 9th edition, Chapter 8 figure 8.3)

enter image description here

Then, my question is that does dynamic loading is occured after dynamic linking? If I'm wrong, what is the exact difference between two concepts?

$\endgroup$
  • $\begingroup$ This is a total cross posting question,this same question was asked 3yrs+ in stackoverflow.So this is a total duplication of this stackoverflow.com/q/10052464/6321488 $\endgroup$ – quintumnia Jun 2 '18 at 17:14
  • 1
    $\begingroup$ " I saw many answers of this topic in Quora, Stackoverflow, and this site. But, I couldn't definitely understand the difference between dynamic loading and dynamic linking." -- What, specifically, didn't you understand? $\endgroup$ – Raphael Jun 3 '18 at 11:27
  • $\begingroup$ I think this question may be offtopic. Community votes, please! $\endgroup$ – Raphael Jun 3 '18 at 11:28
  • 1
    $\begingroup$ @Raphael It's a conceptual question about models of programming. That's computer science. $\endgroup$ – Gilles Jun 5 '18 at 22:33
1
$\begingroup$

Let me explain these terms in the simplest way possible. Now since both the terms have the word dynamic in them, both occur during execution.

Dynamic Loading : Suppose our program that is to be executed consist of various modules. Of course its not wise to load all the modules into main memory together at once(in some cases it might not be even possible because of limited main memory). So basically what we do here is we load the main module first and then during execution we load some other module only when its required and the execution cannot proceed further without loading it.

Dynamic Linking : Suppose our program has some functions whose definition is present in some system library. We do know the header file only consists of declarations of functions and not definitions. So during execution when the function gets called we load that system library into main memory and link the function call inside our program with the function definition inside system library.

$\endgroup$
  • $\begingroup$ Then, in dynamic loading, when linking process occurs? For my knowledge, loading occurs after linking, that's my point. $\endgroup$ – molamola Jun 2 '18 at 12:15
  • $\begingroup$ Yes loading occurs after linking but its not to be confused with dynamic loading. $\endgroup$ – Sumeet Jun 2 '18 at 14:53
  • $\begingroup$ The Diagram shown has nothing to do with dynamic loading. It simply shows the steps that takes place before any execution begins. $\endgroup$ – Sumeet Jun 2 '18 at 14:53
  • $\begingroup$ "Let me explain these terms in the simplest way possible. " -- Why do you think that's helpful? Presumably, other "simple" explanations already failed to help the OP, as they indicate in their question. $\endgroup$ – Raphael Jun 3 '18 at 11:27
0
$\begingroup$

Dynamic loading is the process of loading the dependent library or routine on-demand or at some time at run-time after load-time (the time at which the main program executable is loaded). This is contrast to loading all dependencies at load-time together with the main program. The Windows loader for example supports both techniques. The loading process completes when the library has been successfully loaded into main memory.

When the program attempts to call an imported function for the first time, that library that contains that function may or may not have been loaded yet. Initially, the compiler places a temporary small function, called a stub, that gets called instead of the imported function. The stub calls into the OS. If the library is currently not loaded, it gets loaded (this step is called dynamic loading). Then, the stub is modified so that it calls the imported function directly the next time it gets called. This process is called dynamic linking. The component of the OS that performs both steps is called the dynamic linker or the dynamic linking loader.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.