나무 숲

Demand Paging 본문

Career

Demand Paging

wood.forest 2016. 6. 5. 22:39

Virtual memory can be implemented via.. demand paging & demand segmentation


Demand Paging

- Bring a page into memory only when it is needed

* Less I/O needed 전체 다 안들여와도 되므로

* Less memory needed

* Faster response

* More users 여러개의 프로그램 동작 가능

+) paging이란, physical memory address와 logical memory address사이에서 주소를 변환하는 것


Basic concepts

- h/w support is needed to distinguish between the pages that are in memory and the pages that are on the disk


- Instead of bringing in a whole process, the swapper brings into memory only those pages that will be used; Lazy swapper (or pager)

* Valid-Invalid bit scheme is used

- Valid : the associated page is both legal and in memory

- Invalid : the page either is not valid or is valid but is currently on the disk

(invalid->abort, not in memory->bring to memory)


옆에 그림을 보면 !

logical memory 옆에 있는 번호와 같은 위치에

page table을 보면 valid bit가 들어가 있고 frame에 내용이 있다(frame은 physical memory. page는 logical memory)

page table에 있는 0번의 내용은 4. physical memory로 가보면 4번째 칸에 logical memory의 0번 내용인 A가 들어가 있는 것을 확인할 수 있다





Page fault

- page에 reference가 있다면, first reference to that page will trap to OS

- 그러면 OS는 다른 invalid 테이블을 찾는다. 이것은 empty frame인데 page를 frame으로 swap한다 그 후 테이블을 reset하고 valid bit을 v로 바꾼 후 page fault를 일으킨 명령어를 재시작한다. 

(다시말해 frame이 있는 physical memory에, 필요한 값들 중 없는 것들이 있을 때 logical memory에 있는 page들을 frame으로 스왑. 데려 들어와서 테이블 리셋하고, 이제 들어왔으니 valid bit을 v로 바꾼다 그리고 명령어 재시작)


그림을 보면

1 첫번째 참조 발생

2 원하는 내용이 없으므로 트랩

3 페이지가 backing store에 있으므로 찾아간다

4 페이지를 물리적 메모리에 있는 빈 프레임에 들고 들어온다

5 페이지 테이블 리셋

6 명령어 다시 시작




Performance of demand paging

- page fault rate 0<= p<= 1

p=0 : no page fault

p=1 : every reference is fault

- Effective Access Time (EAT)

= (1-p) * Memory Access Time + p*Page fault time

Page Fault Time = page fault overhead = swap page out + swap page in + restart overhead


Restart Overhead

- 페이지 폴트가 일어나면 우리는 명렁어를 다시 fetch-decode 해야한다

- 만약 블락 두개가 반쯤 겹쳐져 있으면..!(block move) 양 블록의 끝에 접근/겹쳐진 부분의 값을 저장하기 위해 임시 레지스터 이용


Process creation under virtual memory

- 어버이/자녀 둘 다 메모리의 같은 페이지를 공유하도록 초기화딘다

- 만약 한쪽 프로세스에서 공유된 페이지를 수정한다면 그 페이지는 copy된다 (Copy On Write)


예)

프로세스 1이 페이지 c 수정 전


프로세스 1이 페이지 c 수정 후





728x90
반응형

'Career' 카테고리의 다른 글

RISC vs CISC  (0) 2016.06.07
File System  (0) 2016.06.06
Virtual Memory Management Strategy  (0) 2016.06.05
Memory Management  (0) 2016.06.04
Deadlock  (1) 2016.06.04
Comments