32 dynamic linking nd overlays

30
1 Dynamic linking Overlays Storage Management

Transcript of 32 dynamic linking nd overlays

Page 1: 32 dynamic linking nd overlays

1

• Dynamic linking

• Overlays

Storage Management

Page 2: 32 dynamic linking nd overlays

2

HOME PREVIOUS TOPIC NEXTPREVIOUS QUESTION PAPERS FOR OSCPP TUTORIALS

Page 3: 32 dynamic linking nd overlays

3

Recap

In the last class, you have learnt

• Address binding

• Concepts of Dynamic loading

• Advantages of Dynamic loading

Page 4: 32 dynamic linking nd overlays

4

Objectives

On completion of this class, you will be able to

know

• Dynamic linking

• Overlays

Page 5: 32 dynamic linking nd 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

Page 6: 32 dynamic linking nd overlays

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

Page 7: 32 dynamic linking nd overlays

7

Dynamic Linking

printf( ){ ------- ; ------- ; ------- ;}

Memory• main( )

{

---- ;

---- ;

printf( );

---- ;

}

// stub is linked dynamically

Secondary storage

Page 8: 32 dynamic linking nd overlays

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

Page 9: 32 dynamic linking nd overlays

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

Page 10: 32 dynamic linking nd overlays

10

Disadvantages

• Cannot detect the needed routine in another

process memory space

• Support from the operating system is required

Dynamic Linking

Page 11: 32 dynamic linking nd overlays

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

Page 12: 32 dynamic linking nd overlays

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

Page 13: 32 dynamic linking nd overlays

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

Page 14: 32 dynamic linking nd overlays

14

Overlays for a Two-Pass Assembler

Fig - 1

Example 1

Page 15: 32 dynamic linking nd overlays

Example: 2

15

Page 16: 32 dynamic linking nd overlays

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

Page 17: 32 dynamic linking nd overlays

17

• Overlay driver / manager reads the overlays

into the memory

• We can load the given two pass assemblers

into memory and execute them

Overlays

Page 18: 32 dynamic linking nd 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

Page 19: 32 dynamic linking nd 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

Page 20: 32 dynamic linking nd overlays

20

Summary

In this class, you have learnt

• Dynamic linking

-advantages and disadvantages

• Overlays

-advantages and disadvantages

Page 21: 32 dynamic linking nd overlays

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?

Page 22: 32 dynamic linking nd overlays

22

Quiz

1. Concept of Dynamic linking is similar to

a) Dynamic loading

b) Address binding

c) Both

d) None

Page 23: 32 dynamic linking nd overlays

23

2. _________is postponed till execution in

dynamic linking

a) Linking

b) Loading

c) Both

d) None

Quiz

Page 24: 32 dynamic linking nd overlays

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

Page 25: 32 dynamic linking nd overlays

25

4. Support from the operating system is required

a) True

b) False

Quiz

Page 26: 32 dynamic linking nd overlays

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

Page 27: 32 dynamic linking nd overlays

9CM402.32 27

6. ________reads the overlays into the memory

a) Linking driver

b) Operating system

c) Overlay driver

d) None

Quiz

Page 28: 32 dynamic linking nd overlays

Other subject materials

• Web designing

• Micro processors

• C++ tutorials

• java

home

Page 29: 32 dynamic linking nd overlays

9CM402.32 29

7. Programming design of overlay structure is

_______

a) Simple

b) Complex

c) None

Quiz

Page 30: 32 dynamic linking nd overlays

9CM402.32 30

8. Overlays are limited to _____________

a) Minicomputers

b) Microcomputers

c) Mainframe computers

d) None

Quiz