본문 바로가기
시스템sw및실습

[시소실] 4. System Software and Program Execution (2)

by leziwn.cs 2023. 9. 26.

04. System Software and Program Execution .pdf
0.97MB

Static Linking vs. Dynamic Linking

Static Linking vs. Dynamic Linking

▶ Static Linking

  • Static Library: Linker에서 프로그램의 실행파일 코드에 포함된다. (binding: compile time)
    - 실행파일의 크기가 커진다.
    - 동일한 라이브러리를 각각의 프로세스가 메모리에 올리므로, 메모리가 낭비된다.

 

▶ Dynamic Linking

  • Shared Library: Loader에서 라이브러리가 실행 시 link된다. (binding: loading or run time)
    - 실행파일에는 라이브러리 자체가 포함되는 것이 아니라(just mapping), 라이브러리의 위치를 찾기 위한 간단한 코드만 둔다.
    - 라이브러리가 이미 메모리에 있으면 그 루틴의 주소로 가고, 없으면 디스크에서 읽어온다. --> 메모리 낭비x

 

Static Library vs. Shared Library
  • Static Library --> Static Linking
  • Shared Library --> Dynamic Linking

 

Shared Library

▶ Shared Library 장점

  • Many processors share one library function in memory. --> Less memory space
    예) many a.out's calls printf() -- one copy shared.

 

▶ Shared Library 단점

  • Cannot give a.out to others who do not have library.
    Do they have shared library files? Same version?
  • Slower (실행파일 + a: Library call, Binding and loading at run time)
  • Heavy overhead in initial bookeeping during gcc.