The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+23 votes
2.9k views

Which of the following is NOT an advantage of using shared, dynamically linked libraries as opposed to using statistically linked libraries?

  1. Smaller sizes of executable files

  2. Lesser overall page fault rate in the system

  3. Faster program startup

  4. Existing programs need not be re-linked to take advantage of newer versions of libraries

asked in Compiler Design by Veteran (59.5k points) | 2.9k views
0
and what about the draw back of static linked libraries

3 Answers

+42 votes
Best answer

option C: DLL takes more time in program setup (in loading and linking phase to set up the global offset table and load and link the required libraries)

  • Since DLLs are separated from executable, the size of executable becomes smaller. Since DLLs are shared among multiple executables, the total memory usage of the system goes down and hence overall page fault rate decreases.
  • Dynamic linking takes place during program runtime. So, if a DLL is replaced to a new version, it will automatically get linked during runtime. There is no explicit relinking required as in the case of static linking. (This works by linking the DLL calls to Global Offset Table and the contents of this table is filled during program run. A simple jump in static linking becomes an indirect jump in dynamic linking).

Refer: Galvin section 8.1.5, Dynamic Linking and Shared Libraries

answered by Active (1.5k points)
edited by
+1
Why is B) wrong?
+1
it is true
0
So what is the final  answer ? b or c?
0
though during mid of execution static linking will be faster because everything is already linked, so no kernal involvement, no system calls, no unnecessary overheads, but during startup DLL should be faster than static linking, because there will be less overhead to link everything at startup..and program can start without linking everything..
0
so,you are suggesting b as answer?
0
@Arjun Sir,

The answer explains about dynamic and static library but I have read some resources and Galvin also but it does not say anything about page fault. My understanding is that in case of static linking we will load everything at one time and there will be no dependency at run time and all required library are there in Main memory but in case of dynamic linking everytime we need to refer library it will load and run time which creates page fault.So Dynamic linking will have more page faults.

No coming to start up time,i think as static linking will load all the referenced library at compile time so it should take more time and as dynamic library will defer all references to external library till run time so it should take less time at start up.

So B should be correct answer.
0
In made easy book the answer is given as C.
+2

Ref: 

+17 votes

The shared library code is not present in the executable image on disk, but is kept in a separate library file. So size of executable file is smaller.

Operating system is less likely to page out shared library code that is being used by several applications, or copies of an application, rather than code that is only being used by a single application. This causes less page fault. 

But sometimes you may be interested in only a few of the routines in a library, and these routines may be scattered widely in the virtual address space of the library. Thus, the total number of pages you need to touch to access all of your routines is significantly higher than if these routines were all bound directly into your executable program. One impact of this situation is that, if you are the only user of these routines, you experience more page faults to get them all into real memory.

Faster program startup as load time might be reduced because the shared library code might already be in memory.

The routines are not statically bound to the application but are dynamically bound when the application is loaded. This permits applications to automatically inherit changes to the shared libraries, without recompiling or rebinding.

So option A, C and D are always the advantage of the shared DLL. Only option B is not always an advantage.

Reference: http://www.ibm.com/support/knowledgecenter/ssw_aix_72/com.ibm.aix.performance/when_dyn_linking_static_linking.htm

answered by Active (1.1k points)
0
But sometimes you may be interested in only a few of the routines in a library, and these routines may be scattered widely in the virtual address space of the library. Thus, the total number of pages you need to touch to access all of your routines is significantly higher than if these routines were all bound directly into your executable program. One impact of this situation is that, if you are the only user of these routines, you experience more page faults to get them all into real memory.

 

yes, option (b) seems to be incorrect.

 

and also (a)smaller sizes of executables; supports the fact that (b) faster program startup
+13 votes
More Page faults in dynamic linked libraries so solution is "B"
answered by Junior (821 points)
Answer:

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

38,058 questions
45,554 answers
131,894 comments
48,911 users