Download - Paging & Segmentation
Paging &
Segmentation
제 11 강 : Paging 과 Segmentation
프로그램이 크다면 ?
•Swapping•Overlay•비연속 할당기법
빈 공간 List
운영체제
프로그램 A
프로그램 B
프로그램 C
MMU
CPU 에서 Memory 로 가는 주소를 바꿔친다
Add A, B
A: 100
B: 330
Jump C
C: exit
Add 10, 20
10: 100
20: 330
Jump 30
30: exit
memory
Source Binary
CPU 가 보낸 주소를MMU 가 변환
(Memory Management Unit)
Mapping
10 500
논리적 주소
실제주소
Add A, B
A: 100
B: 330
Jump C
C: exit
Add 10, 20
10: 100
20: 330
Jump 30
30: exit
memory
Source Binary 프로그램 running 도중에 옮겨도 된다load 해도 된다
Any time Any place
CPU 가 보낸 주소를MMU 가 변환
(Memory Management Unit)
Mapping
10 500
만일 mapping table 이 있다면10 번지를 아무 곳으로나(anytime, anyplace)
논리적 주소
실제주소
Memory Management Unit
CPU 가 제시한 주소
logical
CPU
Memory500:10
10 maps to 500 실제 memory 내 주소physical
Paging – 동일한 크기
CPU 가 제시한 주소
logical
CPU
Memory500:10
10 maps to 500 실제 memory 내 주소physical
CPU 가 제시한 주소
logical
CPU
Memory500:10
10 maps to 500 실제 memory 내 주소physical
Segmentation – 모두 다른 크기
Logical vs. Physical Address Space
–Logical address•CPU( 프로세스 ) 가 제시한 주소• “virtual address”.
–Physical address •메모리에 실제로 전달되는 주소 .
Paging
Paging
• page• page frame• 전체 executable binary 은 disk 에• CPU 가 참조하는 page 만 메모리로
Memory Disk
pageframe page
CPU 가 제시한 주소
logical
CPU
Memory500:10
10 maps to 500 실제 memory 내 주소physical
Paging아무 page frame 에도 올라온다
Disk
page
MMU
10
500
p d
address from CPU
page numberdisplacement(offset)
10CPU 가 제시한 주소
logical
p d
address from CPU
page numberdisplacement(offset)
p’
p
10CPU 가 제시한 주소
logical
실제 메모리 주소physical
p d
address from CPU
page numberdisplacement(offset)
p’
p
+ p’ d
10
500
CPU 가 제시한 주소
logical
실제 메모리 주소physical
p d
address from CPU
page numberdisplacement(offset)
p’
p
+ p’ d
10
500
CPU 가 제시한 주소
logical
실제 메모리 주소physical
Page Table Base RegisterPage Table Limit Register
Page Table Entry
sector addrpage framerwxR
Resident bit
p d
page numberdisplacement(offset)
p’
p +
10
500
Paging 의 장단점
• 장점 – 외부 단편화 현상이 안 생긴다 .
• 단점 – 페이지 테이블 공간 (table fragmentation)– MMU 하드웨어가 필요– 할당된 마지막 페이지에서 내부단편화
Segmentation
main()
int A[ ][ ];
main(){ ----}
add(){ ----}
A[][]
add()
stack
data rw
code x
data rwa
code x
Segment
• 전체 executable binary 은 disk 에• cpu 가 참조하는 segment 만 메모리로
Memory Disk
page
CPU 가 제시한 주소
logical
CPU
Memory500:10
10 maps to 500 실제 memory 내 주소physical
아무 공간에도 올라온다 Placement – First-fit, Best-fit, Worst-fit
…
Disk
MMU
10
500
Holes
s d
address from CPU
segment numberdisplacement(offset)
s’
s
+ s’ d
10
500
CPU 가 제시한 주소
logical
실제 메모리 주소physical
Segment Table Entry
sector addrs’rwxalengthR
Resident bit