0% found this document useful (0 votes)
750 views

Loading and Linking in Os

Linking combines object modules into an executable program and links libraries, while loading loads the executable into memory. Specifically: 1. Linking generates an executable, while loading loads the executable into memory for execution. 2. Linking processes object modules from assembly, while loading processes the executable from linking. 3. Linking combines objects and links libraries, while loading allocates memory space for the executable. Loading and linking can each be static, loading the entire program at once, or dynamic, loading parts on demand to improve efficiency. Dynamic linking allows shared libraries to be loaded once and updated without recompiling dependent programs.

Uploaded by

daljeet_matharu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
750 views

Loading and Linking in Os

Linking combines object modules into an executable program and links libraries, while loading loads the executable into memory. Specifically: 1. Linking generates an executable, while loading loads the executable into memory for execution. 2. Linking processes object modules from assembly, while loading processes the executable from linking. 3. Linking combines objects and links libraries, while loading allocates memory space for the executable. Loading and linking can each be static, loading the entire program at once, or dynamic, loading parts on demand to improve efficiency. Dynamic linking allows shared libraries to be loaded once and updated without recompiling dependent programs.

Uploaded by

daljeet_matharu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Difference between Loading and Linking

Linking and Loading are the utility programs that play a 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.
Loading:
Bringing the program from secondary memory to main memory is called Loading.
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.

Differences between Linking and Loading:


1. The key difference between linking and loading is that the linking generates the
executable file of a program whereas, the loading loads the executable file obtained from
the linking into main memory for execution.
2. The linking intakes the object module of a program generated by the assembler. However,
the loading intakes the executable module generated by the linking.
3. The linking combines all object modules of a program to generate executable modules it
also links the library function in the object module to built-in libraries of the high-level
programming language. On the other hand, loading allocates space to an executable
module in main memory.
Loading and Linking are further categorized into 2 types:
STATIC DYNAMIC

Loading the entire program into the main


memory before start of the program Loading the program into the main memory on
execution is called as static loading. demand is called as dynamic loading.

Inefficent utilization of memory because


whether it is required or not required entire
program is brought into the main memory. Efficent utilization of memory.

Program execution will be faster. Program execution will be slower.

Statically linked program takes constant load


time every time it is loaded into the memory Dynamic linking is performed at run time by
for execution. the operating system.

If the static loading is used then accordingly If the dynamic loading is used then accordingly
static linking is applied. dynamic linking is applied.

In dynamic linking this is not the case and


Static linking is performed by programs individual shared modules can be updated and
called linkers as the last step in compiling a recompiled.This is one of the greatest
program. Linkers are also called link editors. advantages dynamic linking offers.
STATIC DYNAMIC

In static linking if any of the external


programs has changed then they have to be
recompiled and re-linked again else the In dynamic linking load time might be reduced
changes won’t reflect in existing executable if the shared library code is already present in
file. memory.

Static and Dynamic Linking in Operating Systems


Static Linking:
When we click the .exe (executable) file of the program and it starts running, all the necessary
contents of the binary file have been loaded into the process’s virtual address space. However,
most programs also need to run functions from the system libraries, and these library functions
also need to be loaded.
In the simplest case, the necessary library functions are embedded directly in the program’s
executable binary file. Such a program is statically linked to its libraries, and statically linked
executable codes can commence running as soon as they are loaded.
Disadvantage:
Every program generated must contain copies of exactly the same common system library
functions. In terms of both physical memory and disk-space usage, it is much more efficient to
load the system libraries into memory only once. Dynamic linking allows this single loading
to happen.

Dynamic Linking:
Every dynamically linked program contains a small, statically linked function that is called
when the program starts. This static function only maps the link library into memory and runs
the code that the function contains. The link library determines what are all the dynamic
libraries which the program requires along with the names of the variables and functions
needed from those libraries by reading the information contained in sections of the library.
After which it maps the libraries into the middle of virtual memory and resolves the references
to the symbols contained in those libraries. We don’t know where in the memory these shared
libraries are actually mapped: They are compiled into position-independent code (PIC), that
can run at any address in memory.
Advantage:
Memory requirements of the program are reduced. A DLL is loaded into memory only once,
whereas more than one application may use a single DLL at the moment, thus saving memory
space. Application support and maintenance costs are also lowered.

You might also like