Storage Management

•   Dynamic linking
•   Overlays




                                       1
HOME     PREVIOUS TOPIC NEXT
PREVIOUS QUESTION PAPERS FOR OS
CPP TUTORIALS




                                  2
Recap

In the last class, you have learnt

•   Address binding

•   Concepts of Dynamic loading

•   Advantages of Dynamic loading




                                     3
Objectives


 On completion of this class, you will be able to
  know

• Dynamic linking

• Overlays




                                                    4
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
                                                  5
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
                                                       6
Dynamic Linking
                                Secondary storage
                                   printf( )
     Memory
                                   {
• main( )
                                     ------- ;
  {                                  ------- ;
     ---- ;                          ------- ;
     ---- ;                        }
     printf( );       // stub is linked dynamically
     ---- ;
   }

                                                      7
Dynamic Linking


 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
                                                    8
Dynamic Linking


 Advantages

• All programs that reference the library will

  automatically use new version

• Can allow multiple processes to access the

  same memory address

                                                 9
Dynamic Linking


  Disadvantages

• Cannot detect the needed routine in another

  process memory space

• Support from the operating system is required



                                                  10
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
                                                      11
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
                                                   12
Overlays

• 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)
                                             13
Overlays for a Two-Pass Assembler
             Example 1




              Fig - 1
                                    14
Example: 2




             15
Secondary Storage
             Overlays
       Main Memory          Overlay 1
0K

       Main Program
                            Overlay 2
5k
      Overlay Manager
7k

       Overlay Area
        Overlay 1
                3
                2           Overlay 3

12k
                                            16
Overlays

• Overlay driver / manager reads the overlays
  into the memory
• We can load the given two pass assemblers
  into memory and execute them




                                                17
Overlays

  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

                                                18
Overlays

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
                                                  19
Summary

    In this class, you have learnt
•     Dynamic linking
       -advantages and disadvantages
•    Overlays
      -advantages and disadvantages




                                       20
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?
                                                         21
Quiz

1. Concept of Dynamic linking is similar to

  a) Dynamic loading

  b) Address binding

  c) Both

  d) None


                                              22
Quiz

2. _________is postponed till execution in
  dynamic linking

  a) Linking

  b) Loading

  c) Both

  d) None


                                             23
Quiz

3. _________ is a small piece of code that
  indicates how to load the library routine

  a) Address

  b) Program

  c) Stub

  d) None

                                              24
Quiz

4. Support from the operating system is required

  a) True

  b) False




                                                   25
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               26
Quiz


6. ________reads the overlays into the memory

  a) Linking driver

  b) Operating system

  c) Overlay driver

  d) None


                      9CM402.32                 27
Other subject materials

•   Web designing
•   Micro processors
•   C++ tutorials
•   java

home
Quiz

7. Programming design of overlay structure is

  _______

  a) Simple

  b) Complex

  c) None



                      9CM402.32                 29
Quiz

8. Overlays are limited to _____________

  a) Minicomputers

  b) Microcomputers

  c) Mainframe computers

  d) None




                      9CM402.32            30

32 dynamic linking nd overlays

  • 1.
    Storage Management • Dynamic linking • Overlays 1
  • 2.
    HOME PREVIOUS TOPIC NEXT PREVIOUS QUESTION PAPERS FOR OS CPP TUTORIALS 2
  • 3.
    Recap In the lastclass, you have learnt • Address binding • Concepts of Dynamic loading • Advantages of Dynamic loading 3
  • 4.
    Objectives On completionof this class, you will be able to know • Dynamic linking • Overlays 4
  • 5.
    Dynamic Linking • Conceptof 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 5
  • 6.
    Dynamic Linking • Astub 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 6
  • 7.
    Dynamic Linking Secondary storage printf( ) Memory { • main( ) ------- ; { ------- ; ---- ; ------- ; ---- ; } printf( ); // stub is linked dynamically ---- ; } 7
  • 8.
    Dynamic Linking 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 8
  • 9.
    Dynamic Linking Advantages •All programs that reference the library will automatically use new version • Can allow multiple processes to access the same memory address 9
  • 10.
    Dynamic Linking Disadvantages • Cannot detect the needed routine in another process memory space • Support from the operating system is required 10
  • 11.
    Overlays • Overlay isneeded 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 11
  • 12.
    Overlays Example 1: • Considera 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 12
  • 13.
    Overlays • But only150K 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) 13
  • 14.
    Overlays for aTwo-Pass Assembler Example 1 Fig - 1 14
  • 15.
  • 16.
    Secondary Storage Overlays Main Memory Overlay 1 0K Main Program Overlay 2 5k Overlay Manager 7k Overlay Area Overlay 1 3 2 Overlay 3 12k 16
  • 17.
    Overlays • Overlay driver/ manager reads the overlays into the memory • We can load the given two pass assemblers into memory and execute them 17
  • 18.
    Overlays 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 18
  • 19.
    Overlays Disadvantages • Programming designof 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 19
  • 20.
    Summary In this class, you have learnt • Dynamic linking -advantages and disadvantages • Overlays -advantages and disadvantages 20
  • 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? 21
  • 22.
    Quiz 1. Concept ofDynamic linking is similar to a) Dynamic loading b) Address binding c) Both d) None 22
  • 23.
    Quiz 2. _________is postponedtill execution in dynamic linking a) Linking b) Loading c) Both d) None 23
  • 24.
    Quiz 3. _________ isa small piece of code that indicates how to load the library routine a) Address b) Program c) Stub d) None 24
  • 25.
    Quiz 4. Support fromthe operating system is required a) True b) False 25
  • 26.
    Quiz 5. _________is neededwhen process is larger than amount of memory allocated to it A) Address binding b) Dynamic loading c) Overlays d) Dynamic linking 9CM402.32 26
  • 27.
    Quiz 6. ________reads theoverlays into the memory a) Linking driver b) Operating system c) Overlay driver d) None 9CM402.32 27
  • 28.
    Other subject materials • Web designing • Micro processors • C++ tutorials • java home
  • 29.
    Quiz 7. Programming designof overlay structure is _______ a) Simple b) Complex c) None 9CM402.32 29
  • 30.
    Quiz 8. Overlays arelimited to _____________ a) Minicomputers b) Microcomputers c) Mainframe computers d) None 9CM402.32 30