이 포스트는 서울대학교의 '운영체제의 기초' 강의를 개인 학습용으로 작성한 포스트입니다.
Segmentation
Segmentation의 필요성
두 user process가 동일한 section(코드)을 공유할 수 있도록 함
다른 section 들에게 다른 Read/Write 권한을 설정할 수 있음
하드웨어 구현
Base/Bound address를 table로 만들어 main memory에 저장
STBR (Segment Table Base Register) : Segment table의 시작 주소를 가르키는 MMU의 register
* Context switch마다 OS가 segment table 바꿔야함
-> MMU는 OS에 transparent하지 않음
Segment table
< Segment ID, Base register, Bound register, RW bits >
Segment 관리
PCB에 segment table 복사본 저장
Segment 할당할 공간이 없을 때, 메모리를 압축하거나 Swap함
Segment 공간을 늘려야할 때
1. 바로 위가 비어 있다면 bound register를 업데이트함
2. 바로 위의 공간을 Swap out함
3. 메모리 필요로하는 segment를 디스크로 보내버림 -> 공간이 생겼을 때 할당함
Segmentation 문제점
1. External fragmentation : Countinous 할당 해야함
2. 두 번의 memory access
3. Stack이 계속 커져 용량이 넘칠 수 있음
Paging
Page : Logical adrress space를 일정한 크기로 나눈 memory block
Frame : Physical address space를 일정한 크기로 나눈 memory block, page와 크기가 동일해야 함
Page table
<Page number, Page offset>
PTBR (Page Table Base Register) : Page table의 시작 주소를 가르키는 MMU의 register
Paging 문제점
1. 여러번의 Memory access
2. Page table의 크기가 큼
3. Internal fragmentation
Paged Segmentation
Segmentation한 뒤에, segment별로 paging 수행
Base address 대신 해당 segment의 page table 위치 저장
Bound address 대신 해당 segment의 page 개수 저장
System page table
User page table은 scatter되어 있으므로 이를 mapping하는 page table 존재
System table은 contiguous하고 base/bound register는 physical address여야 함
User base/bound register는 system space에 있는 virtual address

Memory 접근 sequence
1. User page table을 봄 -> 하지만 user page table은 System VM에 있고 그 entry의 virtual address를 얻음 (System address)
2. System page table을 봄 -> System address의 Physical address를 찾음
3. System address를 기준으로 user address가 가르키는 최종 physical address access
Cached page
Uncached page : cache하지 않도록 설정된 page, 여러 프로세스에 의해 동시 접근이 일어날 수 있을 때 사용
Mapped page
Unmapped page : 별도의 주소 변환 없이 바로 접근 가능한 page table등에 사용 (Contiguous)
Machine dependent
CPU micro architecture, System architecture, I/O device에 영향 받는 것
ex) Context switch, Task creation, Memory management, I/O management
TLB
Table Look-aside Buffer
hit ratio 높이기 위해서는 : TLB size 크게, page size 크게, prediction 성능 좋게
구현 방법 : Directed mapped, Set associative, Fully associative
< VPN, PFN, PID, Valid bit, Dirty bit, Don't cache bit >

* OS에 transparent하게 만들 수 있지만 대부분 transparent X
User Memory access in OS
1. OS space는 unmapped으로
2. Mapped이지만, User와 OS 같은 address space 사용
3. Mapped이지만, User와 OS는 분리된 address space 사용
'Basic Learning > Operating System Concepts' 카테고리의 다른 글
I/O Devices and Device Drivers (0) | 2020.06.16 |
---|---|
Demand Paging (0) | 2020.06.16 |
Dynamic Storage Allocation (0) | 2020.06.16 |
GNU Linker (0) | 2020.06.15 |
Deadlock (0) | 2020.06.15 |