32 dynamic linking nd overlays
-
Upload
myrajendra -
Category
Documents
-
view
2.063 -
download
2
Transcript of 32 dynamic linking nd overlays
1
• Dynamic linking
• Overlays
Storage Management
2
HOME PREVIOUS TOPIC NEXTPREVIOUS QUESTION PAPERS FOR OSCPP TUTORIALS
3
Recap
In the last class, you have learnt
• Address binding
• Concepts of Dynamic loading
• Advantages of Dynamic loading
4
Objectives
On completion of this class, you will be able to
know
• Dynamic linking
• Overlays
5
Dynamic Linking
• Concept of dynamic linking is similar to dynamic
loading
• Instead of loading, linking is postponed till
execution
• This feature is used with system libraries
• A stub is included in the image for each library
routine reference
6
Dynamic Linking
• A stub is a small piece of code that indicates
how to load the library routine
• Stub is executed
• It replaces itself with the address of the routine
and executes the routine
• Next time when that code segment is reached
the library routine is executed directly
7
Dynamic Linking
printf( ){ ------- ; ------- ; ------- ;}
Memory• main( )
{
---- ;
---- ;
printf( );
---- ;
}
// stub is linked dynamically
Secondary storage
8
Advantages
• Better memory utilization
• Without this facility the system libraries must
be included in the executable image
• A library may be replaced by a new version
Dynamic Linking
9
Advantages
• All programs that reference the library will
automatically use new version
• Can allow multiple processes to access the
same memory address
Dynamic Linking
10
Disadvantages
• Cannot detect the needed routine in another
process memory space
• Support from the operating system is required
Dynamic Linking
11
Overlays
• Overlay is needed when a process is larger
than, the amount of memory allocated to it
• Keep in memory only those instructions and
data that are needed at any given time
• Other instructions and data are loaded into the
memory space
– occupied by the instructions that are no longer
needed
12
Overlays
Example 1:
• Consider a two pass assembler
• Pass1 : Constructs symbol table ( 70K )
• Pass2 : Generates machine language code ( 80K )
• Common subroutines ( 30K )
• Symbol table ( 20K)
• To load every thing at once we require 200K of memory
13
• But only 150K of memory is available
• Pass1 and Pass2 need not be in memory at
same time
• So define two overlays:
• Overlay A: Symbol table, Common routines
and Pass1 (120K )
• Overlay B: Symbol table, Common routines
and Pass2 (130K)
Overlays
14
Overlays for a Two-Pass Assembler
Fig - 1
Example 1
Example: 2
15
16
Overlays
Overlay Area
Overlay Manager
Main Program
Overlay 1
Overlay 2
Overlay 3
Secondary Storage
Overlay 1Overlay 2Overlay 3Overlay 1
0K
5k
7k
12k
Main Memory
17
• Overlay driver / manager reads the overlays
into the memory
• We can load the given two pass assemblers
into memory and execute them
Overlays
18
Advantages
• No special support is required from the operating
system
• Can execute programs larger than the size of the
memory allocated to it
• Implemented by user
Overlays
19
Disadvantages
• Programming design of overlay structure is
complex
• Process execution is slower due to extra I/O
• Special relocation and linking algorithms are
needed to construct overlays
• Overlays are limited to microcomputers
Overlays
20
Summary
In this class, you have learnt
• Dynamic linking
-advantages and disadvantages
• Overlays
-advantages and disadvantages
21
Frequently Asked Questions
• What is meant by dynamic linking?
• Explain the concept of dynamic linking
• What are the advantages & disadvantages of dynamic
linking?
• What is meant by overlay?
• Explain the concepts of overlays
• What are the advantages & disadvantages of overlays?
22
Quiz
1. Concept of Dynamic linking is similar to
a) Dynamic loading
b) Address binding
c) Both
d) None
23
2. _________is postponed till execution in
dynamic linking
a) Linking
b) Loading
c) Both
d) None
Quiz
24
3. _________ is a small piece of code that
indicates how to load the library routine
a) Address
b) Program
c) Stub
d) None
Quiz
25
4. Support from the operating system is required
a) True
b) False
Quiz
9CM402.32 26
Quiz
5. _________is needed when process is larger
than amount of memory allocated to it
A) Address binding
b) Dynamic loading
c) Overlays
d) Dynamic linking
9CM402.32 27
6. ________reads the overlays into the memory
a) Linking driver
b) Operating system
c) Overlay driver
d) None
Quiz
Other subject materials
• Web designing
• Micro processors
• C++ tutorials
• java
home
9CM402.32 29
7. Programming design of overlay structure is
_______
a) Simple
b) Complex
c) None
Quiz
9CM402.32 30
8. Overlays are limited to _____________
a) Minicomputers
b) Microcomputers
c) Mainframe computers
d) None
Quiz